[PATCH] D154802: [llvm][orc] Consider other ELF init sections as well
Jeff Niu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 9 15:31:50 PDT 2023
Mogball updated this revision to Diff 538460.
Mogball added a comment.
Don't include `.rela` sections
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154802/new/
https://reviews.llvm.org/D154802
Files:
llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
llvm/unittests/ExecutionEngine/Orc/ObjectFormatsTest.cpp
Index: llvm/unittests/ExecutionEngine/Orc/ObjectFormatsTest.cpp
===================================================================
--- llvm/unittests/ExecutionEngine/Orc/ObjectFormatsTest.cpp
+++ llvm/unittests/ExecutionEngine/Orc/ObjectFormatsTest.cpp
@@ -28,6 +28,7 @@
EXPECT_TRUE(isELFInitializerSection(".init_array"));
EXPECT_TRUE(isELFInitializerSection(".init_array.0"));
EXPECT_FALSE(isELFInitializerSection(".text"));
+ EXPECT_TRUE(isELFInitializerSection(".ctors.0"));
}
} // end anonymous namespace
Index: llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
+++ llvm/lib/ExecutionEngine/Orc/Shared/ObjectFormats.cpp
@@ -56,7 +56,19 @@
};
StringRef ELFEHFrameSectionName = ".eh_frame";
+
StringRef ELFInitArrayFuncSectionName = ".init_array";
+StringRef ELFInitFuncSectionName = ".init";
+StringRef ELFFiniArrayFuncSectionName = ".fini_array";
+StringRef ELFFiniFuncSectionName = ".fini";
+StringRef ELFCtorArrayFuncSectionName = ".ctors";
+StringRef ELFDtorArrayFuncSectionName = ".dtors";
+
+StringRef ELFInitSectionNames[6]{
+ ELFInitArrayFuncSectionName, ELFInitFuncSectionName,
+ ELFFiniArrayFuncSectionName, ELFFiniFuncSectionName,
+ ELFCtorArrayFuncSectionName, ELFDtorArrayFuncSectionName,
+};
StringRef ELFThreadBSSSectionName = ".tbss";
StringRef ELFThreadDataSectionName = ".tdata";
@@ -80,9 +92,11 @@
}
bool isELFInitializerSection(StringRef SecName) {
- if (SecName.consume_front(ELFInitArrayFuncSectionName) &&
- (SecName.empty() || SecName[0] == '.'))
- return true;
+ for (StringRef InitSection : ELFInitSectionNames) {
+ StringRef Name = SecName;
+ if (Name.consume_front(InitSection) && (Name.empty() || Name[0] == '.'))
+ return true;
+ }
return false;
}
Index: llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
+++ llvm/include/llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h
@@ -51,7 +51,15 @@
// ELF section names.
extern StringRef ELFEHFrameSectionName;
+
extern StringRef ELFInitArrayFuncSectionName;
+extern StringRef ELFInitFuncSectionName;
+extern StringRef ELFFiniArrayFuncSectionName;
+extern StringRef ELFFiniFuncSectionName;
+extern StringRef ELFCtorArrayFuncSectionName;
+extern StringRef ELFDtorArrayFuncSectionName;
+
+extern StringRef ELFInitSectionNames[6];
extern StringRef ELFThreadBSSSectionName;
extern StringRef ELFThreadDataSectionName;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154802.538460.patch
Type: text/x-patch
Size: 2635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230709/09dfa701/attachment.bin>
More information about the llvm-commits
mailing list