[lld] e057d89 - [ELF][PPC64] Use the regular placement for .branch_lt

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 19:15:47 PDT 2023


Author: Fangrui Song
Date: 2023-09-13T19:15:42-07:00
New Revision: e057d8973cc6a9d0bcc5cc385f318a607d117693

URL: https://github.com/llvm/llvm-project/commit/e057d8973cc6a9d0bcc5cc385f318a607d117693
DIFF: https://github.com/llvm/llvm-project/commit/e057d8973cc6a9d0bcc5cc385f318a607d117693.diff

LOG: [ELF][PPC64] Use the regular placement for .branch_lt

The currently rule places .branch_lt after .data, which does not make
sense. The original contributor probably wanted to place .branch_lt
before .got/.toc, but failed to notice that .got/.toc are RELRO and
placed earlier.

Remove the special case so that .branch_lt is actually closer to .toc,
alleviating the distance issue.

Added: 
    

Modified: 
    lld/ELF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 255f8c334b969bc..d4c667c91ab751a 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -941,12 +941,10 @@ static unsigned getSectionRank(const OutputSection &osec) {
     // their coverage by a single signed 16-bit offset from the TOC base
     // pointer.
     StringRef name = osec.name;
-    if (name == ".branch_lt")
+    if (name == ".got")
       rank |= 1;
-    else if (name == ".got")
-      rank |= 2;
     else if (name == ".toc")
-      rank |= 4;
+      rank |= 2;
   }
 
   if (config->emachine == EM_MIPS) {


        


More information about the llvm-commits mailing list