Add MachO S_MOD_INIT_FUNC_POINTERS section type support

Global data initialization is provided by special section types in the
MachO format whose contents are a list of function pointers to
initialize. Add ObjWriter support for these sections through the
existing CustomSectionAttributes enum.
This commit is contained in:
Simon Nattress 2016-04-06 19:21:48 -07:00
Родитель fba847f397
Коммит 292e21a9f3
7 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -63,6 +63,8 @@ and building both can be found below.
$ cmake -DWITH_CORECLR=../../coreclr/path/to/CoreCLR/binaries -DLLVM_OPTIMIZED_TABLEGEN=ON ..
```
Ie, ../../coreclr/bin/Product/OSX.x64.Debug
5. Build LLVM and LLILC:
```

Просмотреть файл

@ -2,7 +2,7 @@
<package >
<metadata>
<id>Microsoft.DotNet.ObjectWriter</id>
<version>1.0.10-prerelease-00001</version>
<version>1.0.11-prerelease-00001</version>
<title>Microsoft .NET Object File Generator</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>

Просмотреть файл

@ -2,17 +2,17 @@
"runtimes": {
"win7-x64": {
"Microsoft.DotNet.ObjectWriter": {
"toolchain.win7-x64.Microsoft.DotNet.ObjectWriter": "1.0.10-prerelease-00001"
"toolchain.win7-x64.Microsoft.DotNet.ObjectWriter": "1.0.11-prerelease-00001"
}
},
"ubuntu.14.04-x64": {
"Microsoft.DotNet.ObjectWriter": {
"toolchain.ubuntu.14.04-x64.Microsoft.DotNet.ObjectWriter": "1.0.10-prerelease-00001"
"toolchain.ubuntu.14.04-x64.Microsoft.DotNet.ObjectWriter": "1.0.11-prerelease-00001"
}
},
"osx.10.10-x64": {
"Microsoft.DotNet.ObjectWriter": {
"toolchain.osx.10.10-x64.Microsoft.DotNet.ObjectWriter": "1.0.10-prerelease-00001"
"toolchain.osx.10.10-x64.Microsoft.DotNet.ObjectWriter": "1.0.11-prerelease-00001"
}
}
}

Просмотреть файл

@ -2,7 +2,7 @@
<package >
<metadata>
<id>toolchain.osx.10.10-x64.Microsoft.DotNet.ObjectWriter</id>
<version>1.0.10-prerelease-00001</version>
<version>1.0.11-prerelease-00001</version>
<title>Microsoft .NET Object File Generator</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>

Просмотреть файл

@ -2,7 +2,7 @@
<package >
<metadata>
<id>toolchain.ubuntu.14.04-x64.Microsoft.DotNet.ObjectWriter</id>
<version>1.0.10-prerelease-00001</version>
<version>1.0.11-prerelease-00001</version>
<title>Microsoft .NET Object File Generator</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>

Просмотреть файл

@ -2,7 +2,7 @@
<package >
<metadata>
<id>toolchain.win7-x64.Microsoft.DotNet.ObjectWriter</id>
<version>1.0.10-prerelease-00001</version>
<version>1.0.11-prerelease-00001</version>
<title>Microsoft .NET Object File Generator</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>

Просмотреть файл

@ -256,6 +256,7 @@ enum CustomSectionAttributes : int32_t {
CustomSectionAttributes_ReadOnly = 0x0000,
CustomSectionAttributes_Writeable = 0x0001,
CustomSectionAttributes_Executable = 0x0002,
CustomSectionAttributes_MachO_Init_Func_Pointers = 0x0100,
};
extern "C" bool CreateCustomSection(ObjectWriter *OW, const char *SectionName,
@ -281,11 +282,16 @@ extern "C" bool CreateCustomSection(ObjectWriter *OW, const char *SectionName,
: SectionKind::getReadOnly();
switch (TheTriple.getObjectFormat()) {
case Triple::MachO:
case Triple::MachO: {
unsigned typeAndAttributes = 0;
if (attributes & CustomSectionAttributes_MachO_Init_Func_Pointers) {
typeAndAttributes |= MachO::SectionType::S_MOD_INIT_FUNC_POINTERS;
}
Section = OutContext.getMachOSection(
(attributes & CustomSectionAttributes_Executable) ? "__TEXT" : "__DATA",
SectionName, 0, Kind);
SectionName, typeAndAttributes, Kind);
break;
}
case Triple::COFF: {
unsigned Characteristics = COFF::IMAGE_SCN_MEM_READ;