forked from OSchip/llvm-project
revert: [ELF] - Versionscript: support mangled symbols with the same name.
Something broked BBots: 281318 failed on step 9: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/413 r281317 built step 9 green: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/415 Initial revision commits were: This is PR30312. Info from bug page: Both of these symbols demangle to abc::abc(): _ZN3abcC1Ev _ZN3abcC2Ev (These would be abc's complete object constructor and base object constructor, respectively.) however with "abc::abc()" in the version script only one of the two receives the symbol version. Patch fixes that. It uses testcase created by Ed Maste (D24306). Differential revision: https://reviews.llvm.org/D24336 llvm-svn: 281411
This commit is contained in:
parent
610816f268
commit
84ba4ae11d
|
|
@ -603,12 +603,11 @@ static void setVersionId(SymbolBody *Body, StringRef VersionName,
|
||||||
// The relationship is 1:N instead of 1:1 because with the symbol
|
// The relationship is 1:N instead of 1:1 because with the symbol
|
||||||
// versioning, more than one symbol may have the same name.
|
// versioning, more than one symbol may have the same name.
|
||||||
template <class ELFT>
|
template <class ELFT>
|
||||||
std::map<std::string, std::vector<SymbolBody *>>
|
std::map<std::string, SymbolBody *> SymbolTable<ELFT>::getDemangledSyms() {
|
||||||
SymbolTable<ELFT>::getDemangledSyms() {
|
std::map<std::string, SymbolBody *> Result;
|
||||||
std::map<std::string, std::vector<SymbolBody *>> Result;
|
|
||||||
for (Symbol *Sym : SymVector) {
|
for (Symbol *Sym : SymVector) {
|
||||||
SymbolBody *B = Sym->body();
|
SymbolBody *B = Sym->body();
|
||||||
Result[demangle(B->getName())].push_back(B);
|
Result[demangle(B->getName())] = B;
|
||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
@ -621,24 +620,22 @@ static bool hasExternCpp() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayRef<SymbolBody *>
|
static SymbolBody *findDemangled(const std::map<std::string, SymbolBody *> &D,
|
||||||
findDemangled(std::map<std::string, std::vector<SymbolBody *>> &D,
|
StringRef Name) {
|
||||||
StringRef Name) {
|
|
||||||
auto I = D.find(Name);
|
auto I = D.find(Name);
|
||||||
if (I != D.end())
|
if (I != D.end())
|
||||||
return I->second;
|
return I->second;
|
||||||
return {};
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<SymbolBody *>
|
static std::vector<SymbolBody *>
|
||||||
findAllDemangled(const std::map<std::string, std::vector<SymbolBody *>> &D,
|
findAllDemangled(const std::map<std::string, SymbolBody *> &D,
|
||||||
const Regex &Re) {
|
const Regex &Re) {
|
||||||
std::vector<SymbolBody *> Res;
|
std::vector<SymbolBody *> Res;
|
||||||
for (auto &P : D) {
|
for (auto &P : D) {
|
||||||
if (const_cast<Regex &>(Re).match(P.first))
|
SymbolBody *Body = P.second;
|
||||||
for (SymbolBody *Body : P.second)
|
if (!Body->isUndefined() && const_cast<Regex &>(Re).match(P.first))
|
||||||
if (!Body->isUndefined())
|
Res.push_back(Body);
|
||||||
Res.push_back(Body);
|
|
||||||
}
|
}
|
||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
@ -687,7 +684,7 @@ template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
|
||||||
// "llvm::*::foo(int, ?)". Obviously, there's no way to handle this
|
// "llvm::*::foo(int, ?)". Obviously, there's no way to handle this
|
||||||
// other than trying to match a regexp against all demangled symbols.
|
// other than trying to match a regexp against all demangled symbols.
|
||||||
// So, if "extern C++" feature is used, we demangle all known symbols.
|
// So, if "extern C++" feature is used, we demangle all known symbols.
|
||||||
std::map<std::string, std::vector<SymbolBody *>> Demangled;
|
std::map<std::string, SymbolBody *> Demangled;
|
||||||
if (hasExternCpp())
|
if (hasExternCpp())
|
||||||
Demangled = getDemangledSyms();
|
Demangled = getDemangledSyms();
|
||||||
|
|
||||||
|
|
@ -697,13 +694,9 @@ template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
|
||||||
for (SymbolVersion Sym : V.Globals) {
|
for (SymbolVersion Sym : V.Globals) {
|
||||||
if (Sym.HasWildcards)
|
if (Sym.HasWildcards)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
StringRef N = Sym.Name;
|
StringRef N = Sym.Name;
|
||||||
ArrayRef<SymbolBody *> Arr = Sym.IsExternCpp
|
SymbolBody *B = Sym.IsExternCpp ? findDemangled(Demangled, N) : find(N);
|
||||||
? findDemangled(Demangled, N)
|
setVersionId(B, V.Name, N, V.Id);
|
||||||
: ArrayRef<SymbolBody *>(find(N));
|
|
||||||
for (SymbolBody *B : Arr)
|
|
||||||
setVersionId(B, V.Name, N, V.Id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ private:
|
||||||
std::string conflictMsg(SymbolBody *Existing, InputFile *NewFile);
|
std::string conflictMsg(SymbolBody *Existing, InputFile *NewFile);
|
||||||
void reportDuplicate(SymbolBody *Existing, InputFile *NewFile);
|
void reportDuplicate(SymbolBody *Existing, InputFile *NewFile);
|
||||||
|
|
||||||
std::map<std::string, std::vector<SymbolBody *>> getDemangledSyms();
|
std::map<std::string, SymbolBody *> getDemangledSyms();
|
||||||
void handleAnonymousVersion();
|
void handleAnonymousVersion();
|
||||||
|
|
||||||
struct SymIndex {
|
struct SymIndex {
|
||||||
|
|
|
||||||
|
|
@ -64,20 +64,11 @@
|
||||||
# DSO-NEXT: Other: 0
|
# DSO-NEXT: Other: 0
|
||||||
# DSO-NEXT: Section: .text (0x6)
|
# DSO-NEXT: Section: .text (0x6)
|
||||||
# DSO-NEXT: }
|
# DSO-NEXT: }
|
||||||
# DSO-NEXT: Symbol {
|
|
||||||
# DSO-NEXT: Name: _ZN3abcC2Ev@@LIBSAMPLE_1.0
|
|
||||||
# DSO-NEXT: Value: 0x1004
|
|
||||||
# DSO-NEXT: Size: 0
|
|
||||||
# DSO-NEXT: Binding: Global (0x1)
|
|
||||||
# DSO-NEXT: Type: Function (0x2)
|
|
||||||
# DSO-NEXT: Other: 0
|
|
||||||
# DSO-NEXT: Section: .text (0x6)
|
|
||||||
# DSO-NEXT: }
|
|
||||||
# DSO-NEXT: ]
|
# DSO-NEXT: ]
|
||||||
# DSO-NEXT: Version symbols {
|
# DSO-NEXT: Version symbols {
|
||||||
# DSO-NEXT: Section Name: .gnu.version
|
# DSO-NEXT: Section Name: .gnu.version
|
||||||
# DSO-NEXT: Address: 0x258
|
# DSO-NEXT: Address: 0x240
|
||||||
# DSO-NEXT: Offset: 0x258
|
# DSO-NEXT: Offset: 0x240
|
||||||
# DSO-NEXT: Link: 1
|
# DSO-NEXT: Link: 1
|
||||||
# DSO-NEXT: Symbols [
|
# DSO-NEXT: Symbols [
|
||||||
# DSO-NEXT: Symbol {
|
# DSO-NEXT: Symbol {
|
||||||
|
|
@ -100,10 +91,6 @@
|
||||||
# DSO-NEXT: Version: 2
|
# DSO-NEXT: Version: 2
|
||||||
# DSO-NEXT: Name: _ZN3abcC1Ev@@LIBSAMPLE_1.0
|
# DSO-NEXT: Name: _ZN3abcC1Ev@@LIBSAMPLE_1.0
|
||||||
# DSO-NEXT: }
|
# DSO-NEXT: }
|
||||||
# DSO-NEXT: Symbol {
|
|
||||||
# DSO-NEXT: Version: 2
|
|
||||||
# DSO-NEXT: Name: _ZN3abcC2Ev@@LIBSAMPLE_1.0
|
|
||||||
# DSO-NEXT: }
|
|
||||||
# DSO-NEXT: ]
|
# DSO-NEXT: ]
|
||||||
# DSO-NEXT: }
|
# DSO-NEXT: }
|
||||||
|
|
||||||
|
|
@ -127,8 +114,3 @@ retq
|
||||||
.type _ZN3abcC1Ev,@function
|
.type _ZN3abcC1Ev,@function
|
||||||
_ZN3abcC1Ev:
|
_ZN3abcC1Ev:
|
||||||
retq
|
retq
|
||||||
|
|
||||||
.globl _ZN3abcC2Ev
|
|
||||||
.type _ZN3abcC2Ev,@function
|
|
||||||
_ZN3abcC2Ev:
|
|
||||||
retq
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue