[lld] c8d9d00 - [ELF] Relocations: set hasDirectReloc only if not ifunc. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 4 21:30:27 PDT 2022


Author: Fangrui Song
Date: 2022-09-04T21:30:19-07:00
New Revision: c8d9d0000b2f72b50729bfdc7bbb9dd3e9ecd6a0

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

LOG: [ELF] Relocations: set hasDirectReloc only if not ifunc. NFC

Added: 
    

Modified: 
    lld/ELF/Relocations.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 84dba3e91034..4398c0df0b06 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1401,7 +1401,8 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
   // be resolved within the executable will actually be resolved that way at
   // runtime, because the main executable is always at the beginning of a search
   // list. We can leverage that fact.
-  if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt)) {
+  const bool isIfunc = sym.isGnuIFunc();
+  if (!sym.isPreemptible && (!isIfunc || config->zIfuncNoplt)) {
     if (expr != R_GOT_PC) {
       // The 0x8000 bit of r_addend of R_PPC_PLTREL24 is used to choose call
       // stub type. It should be ignored if optimized to R_PC.
@@ -1421,7 +1422,7 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
 
   // We were asked not to generate PLT entries for ifuncs. Instead, pass the
   // direct relocation on through.
-  if (sym.isGnuIFunc() && config->zIfuncNoplt) {
+  if (LLVM_UNLIKELY(isIfunc) && config->zIfuncNoplt) {
     sym.exportDynamic = true;
     mainPart->relaDyn->addSymbolReloc(type, sec, offset, sym, addend, type);
     return;
@@ -1442,7 +1443,7 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
     }
   } else if (needsPlt(expr)) {
     sym.needsPlt = true;
-  } else {
+  } else if (LLVM_UNLIKELY(isIfunc)) {
     sym.hasDirectReloc = true;
   }
 


        


More information about the llvm-commits mailing list