[lld] [llvm] [lld-macho] Fix thunks for non-__text TEXT sections (PR #99052)

Daniel Bertalan via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 12:03:20 PDT 2024


================
@@ -89,9 +90,17 @@ static int sectionOrder(OutputSection *osec) {
   StringRef segname = osec->parent->name;
   // Sections are uniquely identified by their segment + section name.
   if (segname == segment_names::text) {
+    if (osec->name == section_names::header)
+      return -7;
+    if (osec->name == section_names::text)
+      return -6;
+    // Ensure all code sections are contiguous with `__text` for thunk
+    // calculations.
+    if (sections::isCodeSection(osec->name, segment_names::text, osec->flags) &&
+        osec->name != section_names::stubHelper) {
+      return -5;
----------------
BertalanD wrote:

Comment + keeping the jank sounds okay to me, I don't think we'll hit the case when `__text` is not the largest.


https://github.com/llvm/llvm-project/pull/99052


More information about the llvm-commits mailing list