[lld] b841e11 - [ELF] Delete an unused special rule from isStaticLinkTimeConstant. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 09:43:05 PST 2020


Author: Fangrui Song
Date: 2020-01-08T09:41:59-08:00
New Revision: b841e119d77ed0502e3a2e710f26a899bef28b3c

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

LOG: [ELF] Delete an unused special rule from isStaticLinkTimeConstant. NFC

Weak undefined symbols are preemptible after D71794.

  if (sym.isPreemptible)
    return false;
  if (!config->isPic)
    return true;
  // isPic means includeInDynsym is true after D71794.

  ...

  // We can delete this if because it can never be true.
  if (sym.isUndefWeak)
    return true;

Differential Revision: https://reviews.llvm.org/D71795

Added: 
    

Modified: 
    lld/ELF/Relocations.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 894fe2eb93b2..8025779d18dc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -404,17 +404,7 @@ static bool isStaticLinkTimeConstant(RelExpr e, RelType type, const Symbol &sym,
   if (!absVal && !relE)
     return target->usesOnlyLowPageBits(type);
 
-  // Relative relocation to an absolute value. This is normally unrepresentable,
-  // but if the relocation refers to a weak undefined symbol, we allow it to
-  // resolve to the image base. This is a little strange, but it allows us to
-  // link function calls to such symbols. Normally such a call will be guarded
-  // with a comparison, which will load a zero from the GOT.
-  // Another special case is MIPS _gp_disp symbol which represents offset
-  // between start of a function and '_gp' value and defined as absolute just
-  // to simplify the code.
   assert(absVal && relE);
-  if (sym.isUndefWeak())
-    return true;
 
   // We set the final symbols values for linker script defined symbols later.
   // They always can be computed as a link time constant.


        


More information about the llvm-commits mailing list