[lld] [lld/ELF][x86-64] Place large executable sections at the edges of binary (PR #70358)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 14:50:36 PDT 2025


================
@@ -722,7 +725,16 @@ unsigned elf::getSectionRank(Ctx &ctx, OutputSection &osec) {
     else
       rank |= RF_RODATA;
   } else if (isExec) {
-    rank |= isWrite ? RF_EXEC_WRITE : RF_EXEC;
+    // Place readonly .ltext before .lrodata and writable .ltext after .lbss to
+    // keep writable and readonly segments separate.
+    if (isLarge) {
+      if (isWrite)
----------------
rnk wrote:

This can be a one-liner with a ternary conditional and it will match the else case, which is easier to read. I don't know if I would go so far as to do nested ternaries, but it seems like other simplifications are possible.

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


More information about the llvm-commits mailing list