This is an archive of the discontinued LLVM Phabricator instance.

[llvm][orc] Consider other ELF init sections as well
ClosedPublic

Authored by Mogball on Jul 9 2023, 3:24 PM.

Details

Summary

ELF object files can contain .ctors and .dtors sections that also
participate as initializers.

Diff Detail

Event Timeline

Mogball created this revision.Jul 9 2023, 3:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2023, 3:24 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Mogball requested review of this revision.Jul 9 2023, 3:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2023, 3:24 PM
Mogball updated this revision to Diff 538460.Jul 9 2023, 3:31 PM

Don't include .rela sections

Mostly looks good, but should .dtors be included as an init section? I don't think ELFNixPlatform has any special case logic for .dtors yet, which might lead to functions in .dtors being run immediately upon load.

It may take some changes on the ELFNixPlatform side to make .dtors work.

I don't think ELFNixPlatform has any special case logic for .dtors yet, which might lead to functions in .dtors being run immediately upon load.

You are right. I double-checked this and it is causing the dtors to run upon load. I'll comment dtors out and file an issue to fix this in ELFNixPlatform. Thanks for taking a look!

Mogball updated this revision to Diff 542064.Jul 19 2023, 9:13 AM

drop fini and dtors from init sections

lhames accepted this revision.Jul 25 2023, 8:08 AM

LGTM. Thanks @Mogball!

This revision is now accepted and ready to land.Jul 25 2023, 8:08 AM
This revision was landed with ongoing or failed builds.Jul 26 2023, 1:44 PM
This revision was automatically updated to reflect the committed changes.