Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Commit

Permalink
Add MachO S_MOD_INIT_FUNC_POINTERS section type support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nattress committed Apr 7, 2016
1 parent fba847f commit 292e21a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Documentation/Getting-Started-For-Linux-and-OS-X.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand Down
2 changes: 1 addition & 1 deletion lib/ObjWriter/.nuget/Microsoft.DotNet.ObjectWriter.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions lib/ObjWriter/.nuget/runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 8 additions & 2 deletions lib/ObjWriter/objwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down

0 comments on commit 292e21a

Please sign in to comment.