[lld] r292228 - Add a isInCurrentDSO helper. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 08:08:07 PST 2017


Author: rafael
Date: Tue Jan 17 10:08:06 2017
New Revision: 292228

URL: http://llvm.org/viewvc/llvm-project?rev=292228&view=rev
Log:
Add a isInCurrentDSO helper. NFC.

Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/SymbolTable.h
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=292228&r1=292227&r2=292228&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Jan 17 10:08:06 2017
@@ -283,7 +283,7 @@ static int compareDefined(Symbol *S, boo
   if (WasInserted)
     return 1;
   SymbolBody *Body = S->body();
-  if (Body->isLazy() || Body->isUndefined() || Body->isShared())
+  if (Body->isLazy() || !Body->isInCurrentDSO())
     return 1;
   if (Binding == STB_WEAK)
     return -1;
@@ -464,9 +464,9 @@ template <class ELFT> SymbolBody *Symbol
 }
 
 template <class ELFT>
-SymbolBody *SymbolTable<ELFT>::findDefined(StringRef Name) {
+SymbolBody *SymbolTable<ELFT>::findInCurrentDSO(StringRef Name) {
   if (SymbolBody *S = find(Name))
-    if (S->isDefined() && !S->isShared())
+    if (S->isInCurrentDSO())
       return S;
   return nullptr;
 }

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=292228&r1=292227&r2=292228&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Tue Jan 17 10:08:06 2017
@@ -82,7 +82,7 @@ public:
   void scanVersionScript();
 
   SymbolBody *find(StringRef Name);
-  SymbolBody *findDefined(StringRef Name);
+  SymbolBody *findInCurrentDSO(StringRef Name);
 
   void trace(StringRef Name);
   void wrap(StringRef Name);

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=292228&r1=292227&r2=292228&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Jan 17 10:08:06 2017
@@ -203,8 +203,8 @@ void SymbolBody::parseSymbolVersion() {
   // Truncate the symbol name so that it doesn't include the version string.
   Name = {S.data(), Pos};
 
-  // If this is an undefined or shared symbol it is not a definition.
-  if (isUndefined() || isShared())
+  // If this is not in this DSO, it is not a definition.
+  if (!isInCurrentDSO())
     return;
 
   // '@@' in a symbol name means the default version.
@@ -300,7 +300,7 @@ uint8_t Symbol::computeBinding() const {
   if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
     return STB_LOCAL;
   const SymbolBody *Body = body();
-  if (VersionId == VER_NDX_LOCAL && !Body->isUndefined() && !Body->isShared())
+  if (VersionId == VER_NDX_LOCAL && Body->isInCurrentDSO())
     return STB_LOCAL;
   if (Config->NoGnuUnique && Binding == STB_GNU_UNIQUE)
     return STB_GLOBAL;

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=292228&r1=292227&r2=292228&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Jan 17 10:08:06 2017
@@ -67,6 +67,7 @@ public:
     return SymbolKind == LazyArchiveKind || SymbolKind == LazyObjectKind;
   }
   bool isShared() const { return SymbolKind == SharedKind; }
+  bool isInCurrentDSO() const { return !isUndefined() && !isShared(); }
   bool isLocal() const { return IsLocal; }
   bool isPreemptible() const;
   StringRef getName() const { return Name; }

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=292228&r1=292227&r2=292228&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Jan 17 10:08:06 2017
@@ -883,9 +883,9 @@ template <class ELFT> void DynamicSectio
     add({DT_FINI_ARRAYSZ, Out<ELFT>::FiniArray, Entry::SecSize});
   }
 
-  if (SymbolBody *B = Symtab<ELFT>::X->findDefined(Config->Init))
+  if (SymbolBody *B = Symtab<ELFT>::X->findInCurrentDSO(Config->Init))
     add({DT_INIT, B});
-  if (SymbolBody *B = Symtab<ELFT>::X->findDefined(Config->Fini))
+  if (SymbolBody *B = Symtab<ELFT>::X->findInCurrentDSO(Config->Fini))
     add({DT_FINI, B});
 
   bool HasVerNeed = In<ELFT>::VerNeed->getNeedNum() != 0;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=292228&r1=292227&r2=292228&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jan 17 10:08:06 2017
@@ -664,7 +664,7 @@ static void addOptionalSynthetic(StringR
                                  typename ELFT::uint Val,
                                  uint8_t StOther = STV_HIDDEN) {
   if (SymbolBody *S = Symtab<ELFT>::X->find(Name))
-    if (S->isUndefined() || S->isShared())
+    if (!S->isInCurrentDSO())
       Symtab<ELFT>::X->addSynthetic(Name, Sec, Val, StOther);
 }
 
@@ -684,7 +684,7 @@ static Symbol *addOptionalRegular(String
   SymbolBody *S = Symtab<ELFT>::X->find(Name);
   if (!S)
     return nullptr;
-  if (!S->isUndefined() && !S->isShared())
+  if (S->isInCurrentDSO())
     return S->symbol();
   return addRegular(Name, IS, Value);
 }




More information about the llvm-commits mailing list