/usr/include/d/ldc/msvc.c is in libphobos2-ldc-dev 1:0.17.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | /**
* Implementation of support routines for synchronized blocks.
*
* Copyright: Copyright The LDC Developers 2012
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: Kai Nacke <kai@redstar.de>
*/
/* Copyright The LDC Developers 2012.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/* ================================= Win32 ============================ */
#if _WIN32
#if _MSC_VER || __MINGW64__
#include <Windows.h>
#include <string.h>
const char* _data_start__;
const char* _data_end__;
const char* _bss_start__;
const char* _bss_end__;
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
static void init_data_seg(void)
{
// Get handle to this module (.exe/.dll)
HMODULE hModule = (HMODULE) &__ImageBase;
char* imageBase = (char*) hModule;
// Get the DOS header
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER) hModule;
// Get the address of the NT headers
PIMAGE_NT_HEADERS pNtHeaders = (PIMAGE_NT_HEADERS) (imageBase + pDosHeader->e_lfanew);
// After the NT headers comes the sections table
PIMAGE_SECTION_HEADER pSectionHeader = (PIMAGE_SECTION_HEADER) (pNtHeaders + 1);
// Iterate over all sections
for (int i = 0; i < pNtHeaders->FileHeader.NumberOfSections; i++)
{
BYTE* name = pSectionHeader->Name;
if (memcmp(name, ".data", 6) == 0)
{
_data_start__ = imageBase + pSectionHeader->VirtualAddress;
_data_end__ = _data_start__ + pSectionHeader->Misc.VirtualSize;
}
else if (memcmp(name, ".bss", 5) == 0)
{
_bss_start__ = imageBase + pSectionHeader->VirtualAddress;
_bss_end__ = _bss_start__ + pSectionHeader->Misc.VirtualSize;
}
pSectionHeader++;
}
}
typedef int (__cdecl *_PF)(void);
static int __cdecl ctor(void)
{
init_data_seg();
return 0;
}
static int __cdecl dtor(void)
{
return 0;
}
#pragma data_seg(push)
#pragma section(".CRT$XIY", long, read)
#pragma section(".CRT$XTY", long, read)
#pragma data_seg(".CRT$XIY")
__declspec(allocate(".CRT$XIY")) static _PF _ctor = &ctor;
#pragma data_seg(".CRT$XTY")
__declspec(allocate(".CRT$XTY")) static _PF _dtor = &dtor;
#pragma data_seg(pop)
#endif
#endif
|