Pull in r328738 from upstream lld trunk (by Rafael Espindola):

Strip @VER suffices from the LTO output.

  This fixes pr36623.

  The problem is that we have to parse versions out of names before LTO
  so that LTO can use that information.

  When we get the LTO produced .o files, we replace the previous symbols
  with the LTO produced ones, but they still have @ in their names.

  We could just trim the name directly, but calling parseSymbolVersion
  to do it is simpler.

This is a follow-up to r331366, since we discovered that lld could
append version strings to symbols twice, when using Link Time
Optimization.

MFC after:	3 months
X-MFC-With:	r327952
This commit is contained in:
Dimitry Andric 2018-03-29 13:55:23 +00:00
parent 39bb4f84d4
commit 222ab3169e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331731
3 changed files with 9 additions and 1 deletions

View File

@ -281,6 +281,10 @@ template <class ELFT> ArrayRef<Symbol *> ObjFile<ELFT>::getLocalSymbols() {
return makeArrayRef(this->Symbols).slice(1, this->FirstNonLocal - 1);
}
template <class ELFT> ArrayRef<Symbol *> ObjFile<ELFT>::getGlobalSymbols() {
return makeArrayRef(this->Symbols).slice(this->FirstNonLocal);
}
template <class ELFT>
void ObjFile<ELFT>::parse(DenseSet<CachedHashStringRef> &ComdatGroups) {
// Read section and symbol tables.

View File

@ -167,6 +167,7 @@ template <class ELFT> class ObjFile : public ELFFileBase<ELFT> {
static bool classof(const InputFile *F) { return F->kind() == Base::ObjKind; }
ArrayRef<Symbol *> getLocalSymbols();
ArrayRef<Symbol *> getGlobalSymbols();
ObjFile(MemoryBufferRef M, StringRef ArchiveName);
void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);

View File

@ -130,7 +130,10 @@ template <class ELFT> void SymbolTable::addCombinedLTOObject() {
for (InputFile *File : LTO->compile()) {
DenseSet<CachedHashStringRef> DummyGroups;
cast<ObjFile<ELFT>>(File)->parse(DummyGroups);
auto *Obj = cast<ObjFile<ELFT>>(File);
Obj->parse(DummyGroups);
for (Symbol *Sym : Obj->getGlobalSymbols())
Sym->parseSymbolVersion();
ObjectFiles.push_back(File);
}
}