[lld] r292620 - Port r292228.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 09:38:03 PST 2017
Author: rafael
Date: Fri Jan 20 11:38:03 2017
New Revision: 292620
URL: http://llvm.org/viewvc/llvm-project?rev=292620&view=rev
Log:
Port r292228.
Add a isInCurrentDSO helper. NFC.
Modified:
lld/branches/release_40/ELF/SymbolTable.cpp
lld/branches/release_40/ELF/SymbolTable.h
lld/branches/release_40/ELF/Symbols.cpp
lld/branches/release_40/ELF/Symbols.h
lld/branches/release_40/ELF/SyntheticSections.cpp
lld/branches/release_40/ELF/Writer.cpp
Modified: lld/branches/release_40/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/SymbolTable.cpp?rev=292620&r1=292619&r2=292620&view=diff
==============================================================================
--- lld/branches/release_40/ELF/SymbolTable.cpp (original)
+++ lld/branches/release_40/ELF/SymbolTable.cpp Fri Jan 20 11:38:03 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/branches/release_40/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/SymbolTable.h?rev=292620&r1=292619&r2=292620&view=diff
==============================================================================
--- lld/branches/release_40/ELF/SymbolTable.h (original)
+++ lld/branches/release_40/ELF/SymbolTable.h Fri Jan 20 11:38:03 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/branches/release_40/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/Symbols.cpp?rev=292620&r1=292619&r2=292620&view=diff
==============================================================================
--- lld/branches/release_40/ELF/Symbols.cpp (original)
+++ lld/branches/release_40/ELF/Symbols.cpp Fri Jan 20 11:38:03 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/branches/release_40/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/Symbols.h?rev=292620&r1=292619&r2=292620&view=diff
==============================================================================
--- lld/branches/release_40/ELF/Symbols.h (original)
+++ lld/branches/release_40/ELF/Symbols.h Fri Jan 20 11:38:03 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/branches/release_40/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/SyntheticSections.cpp?rev=292620&r1=292619&r2=292620&view=diff
==============================================================================
--- lld/branches/release_40/ELF/SyntheticSections.cpp (original)
+++ lld/branches/release_40/ELF/SyntheticSections.cpp Fri Jan 20 11:38:03 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/branches/release_40/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/Writer.cpp?rev=292620&r1=292619&r2=292620&view=diff
==============================================================================
--- lld/branches/release_40/ELF/Writer.cpp (original)
+++ lld/branches/release_40/ELF/Writer.cpp Fri Jan 20 11:38:03 2017
@@ -641,7 +641,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);
}
@@ -661,7 +661,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