aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-01-20 17:38:03 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-01-20 17:38:03 +0000
commitcedbd831e6799a01d946be5b396e30bbd1fabc60 (patch)
treeaa8b3a9dbbac43432b5109d36a27aa409dc2031b
parent83a83a52d143ff3d21ab86fbc884fb2caa211cbc (diff)
Port r292228.
Add a isInCurrentDSO helper. NFC. git-svn-id: https://llvm.org/svn/llvm-project/lld/branches/release_40@292620 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/SymbolTable.cpp6
-rw-r--r--ELF/SymbolTable.h2
-rw-r--r--ELF/Symbols.cpp6
-rw-r--r--ELF/Symbols.h1
-rw-r--r--ELF/SyntheticSections.cpp4
-rw-r--r--ELF/Writer.cpp4
6 files changed, 12 insertions, 11 deletions
diff --git a/ELF/SymbolTable.cpp b/ELF/SymbolTable.cpp
index 43b39bcb1..abf97f4fc 100644
--- a/ELF/SymbolTable.cpp
+++ b/ELF/SymbolTable.cpp
@@ -283,7 +283,7 @@ static int compareDefined(Symbol *S, bool WasInserted, uint8_t Binding) {
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 *SymbolTable<ELFT>::find(StringRef Name) {
}
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;
}
diff --git a/ELF/SymbolTable.h b/ELF/SymbolTable.h
index bfed1a798..f39dbd1e2 100644
--- a/ELF/SymbolTable.h
+++ b/ELF/SymbolTable.h
@@ -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);
diff --git a/ELF/Symbols.cpp b/ELF/Symbols.cpp
index 7c2b5fb95..0fe42be25 100644
--- a/ELF/Symbols.cpp
+++ b/ELF/Symbols.cpp
@@ -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;
diff --git a/ELF/Symbols.h b/ELF/Symbols.h
index af85dc2b1..7acb89ad0 100644
--- a/ELF/Symbols.h
+++ b/ELF/Symbols.h
@@ -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; }
diff --git a/ELF/SyntheticSections.cpp b/ELF/SyntheticSections.cpp
index 302a6ee51..f09b60b2b 100644
--- a/ELF/SyntheticSections.cpp
+++ b/ELF/SyntheticSections.cpp
@@ -883,9 +883,9 @@ template <class ELFT> void DynamicSection<ELFT>::finalize() {
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;
diff --git a/ELF/Writer.cpp b/ELF/Writer.cpp
index bddc42e1a..4f2f91993 100644
--- a/ELF/Writer.cpp
+++ b/ELF/Writer.cpp
@@ -641,7 +641,7 @@ static void addOptionalSynthetic(StringRef Name, OutputSectionBase *Sec,
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(StringRef Name, InputSectionBase<ELFT> *IS,
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);
}