[lld] 7330fd2 - [ELF] Simplify Symbol::includeInDynsym

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 15 23:27:50 PST 2022


Author: Fangrui Song
Date: 2022-01-15T23:27:45-08:00
New Revision: 7330fd236ef02462f8771b016201ea039d46842b

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

LOG: [ELF] Simplify Symbol::includeInDynsym

Added: 
    

Modified: 
    lld/ELF/ICF.cpp
    lld/ELF/Symbols.cpp
    lld/ELF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index ec63d2ef4d6f..3b991e8d3470 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -461,8 +461,9 @@ template <class ELFT> void ICF<ELFT>::run() {
   // Compute isPreemptible early. We may add more symbols later, so this loop
   // cannot be merged with the later computeIsPreemptible() pass which is used
   // by scanRelocations().
-  for (Symbol *sym : symtab->symbols())
-    sym->isPreemptible = computeIsPreemptible(*sym);
+  if (config->hasDynSymTab)
+    for (Symbol *sym : symtab->symbols())
+      sym->isPreemptible = computeIsPreemptible(*sym);
 
   // Two text sections may have identical content and relocations but 
diff erent
   // LSDA, e.g. the two functions may have catch blocks of 
diff erent types. If a

diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index f3bd67b85873..2be5e8d9510c 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -279,8 +279,6 @@ uint8_t Symbol::computeBinding() const {
 }
 
 bool Symbol::includeInDynsym() const {
-  if (!config->hasDynSymTab)
-    return false;
   if (computeBinding() == STB_LOCAL)
     return false;
   if (!isDefined() && !isCommon())

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7249368fe912..b87123a216bc 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1912,8 +1912,9 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
       finalizeSynthetic(part.ehFrame.get());
   }
 
-  for (Symbol *sym : symtab->symbols())
-    sym->isPreemptible = computeIsPreemptible(*sym);
+  if (config->hasDynSymTab)
+    for (Symbol *sym : symtab->symbols())
+      sym->isPreemptible = computeIsPreemptible(*sym);
 
   // Change values of linker-script-defined symbols from placeholders (assigned
   // by declareSymbols) to actual definitions.


        


More information about the llvm-commits mailing list