[llvm-branch-commits] [ELF] Place .lbss/.lrodata/.ldata after .bss (PR #81224)

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 9 13:05:18 PST 2024


================
@@ -1103,31 +1106,36 @@ template <class ELFT> void Writer<ELFT>::setReservedSymbolSections() {
   }
 
   PhdrEntry *last = nullptr;
-  PhdrEntry *lastRO = nullptr;
-
+  OutputSection *lastRO = nullptr;
+  auto isLarge = [](OutputSection *osec) {
+    return config->emachine == EM_X86_64 && osec->flags & SHF_X86_64_LARGE;
+  };
   for (Partition &part : partitions) {
     for (PhdrEntry *p : part.phdrs) {
       if (p->p_type != PT_LOAD)
         continue;
       last = p;
-      if (!(p->p_flags & PF_W))
-        lastRO = p;
+      if (!(p->p_flags & PF_W) && p->lastSec && !isLarge(p->lastSec))
----------------
MaskRay wrote:

This is a new change. We need to adjust `_etext` as there is now a read-only PT_LOAD segment after RW PT_LOAD segments. (Mentioned in the updated description).

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


More information about the llvm-branch-commits mailing list