Repository navigation
Merge ReadyToRun header pointers on Unix platforms - #1089
Conversation
| __attribute((section (".modules$A"))) void * __modules_a[] = { nullptr }; | ||
| __attribute((section (".modules$Z"))) void * __modules_z[] = { nullptr }; | ||
|
|
||
| extern "C" void * __modules_a[]; |
There was a problem hiding this comment.
Not sure yet - I should have tagged this as WIP since I need to get OSX working before this is done. Jan moved this code into bootstrap which should be the only place it's used so we may no longer need the externs.
|
@MichalStrehovsky Ok this is now complete - PTAL :) I need dotnet/llilc#1049 to go through first so this will work on the CI box, though. |
| // data pointer into RegisterReadyToRunModule where we save it in a list for the startup | ||
| // code to consume. | ||
| // | ||
| std::vector<void*> __registeredModules; |
There was a problem hiding this comment.
It would be nice to not introduce dependency on C++ STL - it pulls in a pile of stuff that we do not have/need.
|
Just a thought - would it make things simple if we used the same scheme on Linux as what you have built for OSX? |
|
LGTM |
| @@ -0,0 +1,17 @@ | |||
| // Licensed to the .NET Foundation under one or more agreements. | |||
There was a problem hiding this comment.
The file naming convention seem to be "X64NodeType" so this would be X64SingleArgumentJumpThunk.cs". I don't necessarily agree with the convention, but let's be consistent.
|
LGTM otherwise. |
|
Looking at the ELF spec, it looks like there's a MachO equivalent for a section with an array of init pointers: ELF::SHT_INIT_ARRAY. I'll look into this for a follow up check-in. |
Linux Add a linker script which controls how sections are merged to group together module header indirection cells. This allows the ReadyToRun headers to be collated and iterated at start up. The updated CLI looks for a file named "linkerscript" in the CoreRT SDK folder and passes it to the linker on Unix platforms if so. Remove work-around for Unix from ModulesSectionNode that was inserting symbols for __modules_a and __modules_z which are now consumed from those defined in main.cpp and linked in from libbootstrapper.a OSX On Windows / Linux each compiled object file contains a section, .Modules$I, which has a pointer to the ReadyToRun header describing the module's global data. The linker on those platforms collects all object file .Modules$I sections and sandwiches them between two other sections:.Modules$A and .Modules$Z in which we store sentinel symbols available at runtime to iterate the list of ReadyToRun headers. On OSX the linker doesn't support this model. Instead, a MachO section with the type S_MOD_INIT_FUNC_POINTERS can be created. In that section, place a function pointer. At binary load time, the OS loader will scan for these sections and call all functions in them. Introduce a jump thunk in the compiler that carries the ReadyToRun header address in it. At runtime, it calls a native helper which collects all headers and passes them to the regular startup code.
Add a linker script which controls how sections are merged to group
together module header indirection cells. This allows the ReadyToRun
headers to be collated and iterated at start up. The updated CLI looks
for a file named "linkerscript" in the CoreRT SDK folder and passes it
to the linker on Unix platforms if so.
Remove work-around for Unix from ModulesSectionNode that was inserting
symbols for __modules_a and __modules_z which are now consumed from
those defined in main.cpp and linked in from libbootstrapper.a