diff options
author | Peter S. Housel <housel@acm.org> | 2022-06-03 23:14:04 -0700 |
---|---|---|
committer | Peter S. Housel <housel@acm.org> | 2022-06-09 22:47:58 -0700 |
commit | 2be5abb7e9a1f837c550745900f0fb155b440122 (patch) | |
tree | 38ea2a9347efb74f0c28c3ed787fb0fb754a0690 /llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp | |
parent | 1aa71f8679e439db651c06e8e68ef21e6deffa93 (diff) | |
download | llvm-2be5abb7e9a1f837c550745900f0fb155b440122.zip llvm-2be5abb7e9a1f837c550745900f0fb155b440122.tar.gz llvm-2be5abb7e9a1f837c550745900f0fb155b440122.tar.bz2 |
[ORC][ORC_RT] Handle ELF .init_array with non-default priority
ELF-based platforms currently support defining multiple static
initializer table sections with differing priorities, for example
.init_array.0 or .init_array.100; the default .init_array corresponds
to a priority of 65535. When building a shared library or executable,
the system linker normally sorts these sections and combines them into
a single .init_array section. This change adds the capability to
recognize ELF static initializers with priorities other than the
default, and to properly sort them by priority, to Orc and the Orc
runtime.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D127056
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp index 4461b6c..5ddb35c 100644 --- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp @@ -78,9 +78,12 @@ private: } static bool hasELFInitSection(LinkGraph &G) { - for (auto &Sec : G.sections()) - if (Sec.getName() == ".init_array") + for (auto &Sec : G.sections()) { + auto SecName = Sec.getName(); + if (SecName.consume_front(".init_array") && + (SecName.empty() || SecName[0] == '.')) return true; + } return false; } |