[lld] a4d4b45 - [ELF] relocateNonAlloc: move likely expr == R_ABS before unlikely R_SIZE. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 12:11:55 PST 2023


Author: Fangrui Song
Date: 2023-12-07T12:10:42-08:00
New Revision: a4d4b45aef6dbac1cead60dcba5e60939fc1656d

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

LOG: [ELF] relocateNonAlloc: move likely expr == R_ABS before unlikely R_SIZE. NFC

Added: 
    

Modified: 
    lld/ELF/InputSection.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 145d55d9a0a4b..2c06bb594158c 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -999,20 +999,20 @@ void InputSection::relocateNonAlloc(uint8_t *buf, ArrayRef<RelTy> rels) {
     if (config->relocatable && (RelTy::IsRela || sym.type != STT_SECTION))
       continue;
 
-    if (expr == R_SIZE) {
-      target.relocateNoSym(bufLoc, type,
-                           SignExtend64<bits>(sym.getSize() + addend));
-      continue;
-    }
-
     // R_ABS/R_DTPREL and some other relocations can be used from non-SHF_ALLOC
     // sections.
-    if (expr == R_ABS || expr == R_DTPREL || expr == R_GOTPLTREL ||
+    if (LLVM_LIKELY(expr == R_ABS) || expr == R_DTPREL || expr == R_GOTPLTREL ||
         expr == R_RISCV_ADD) {
       target.relocateNoSym(bufLoc, type, SignExtend64<bits>(sym.getVA(addend)));
       continue;
     }
 
+    if (expr == R_SIZE) {
+      target.relocateNoSym(bufLoc, type,
+                           SignExtend64<bits>(sym.getSize() + addend));
+      continue;
+    }
+
     std::string msg = getLocation(offset) + ": has non-ABS relocation " +
                       toString(type) + " against symbol '" + toString(sym) +
                       "'";


        


More information about the llvm-commits mailing list