From 222ab3169e6a2cf19c05a7dc19f643d431169eb5 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 29 Mar 2018 13:55:23 +0000 Subject: 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 --- contrib/llvm/tools/lld/ELF/InputFiles.cpp | 4 ++++ contrib/llvm/tools/lld/ELF/InputFiles.h | 1 + contrib/llvm/tools/lld/ELF/SymbolTable.cpp | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/llvm/tools/lld/ELF/InputFiles.cpp b/contrib/llvm/tools/lld/ELF/InputFiles.cpp index ccf4b3d7673f..52c65dd8ee70 100644 --- a/contrib/llvm/tools/lld/ELF/InputFiles.cpp +++ b/contrib/llvm/tools/lld/ELF/InputFiles.cpp @@ -281,6 +281,10 @@ template ArrayRef ObjFile::getLocalSymbols() { return makeArrayRef(this->Symbols).slice(1, this->FirstNonLocal - 1); } +template ArrayRef ObjFile::getGlobalSymbols() { + return makeArrayRef(this->Symbols).slice(this->FirstNonLocal); +} + template void ObjFile::parse(DenseSet &ComdatGroups) { // Read section and symbol tables. diff --git a/contrib/llvm/tools/lld/ELF/InputFiles.h b/contrib/llvm/tools/lld/ELF/InputFiles.h index dda1de81570c..70109f002e98 100644 --- a/contrib/llvm/tools/lld/ELF/InputFiles.h +++ b/contrib/llvm/tools/lld/ELF/InputFiles.h @@ -167,6 +167,7 @@ public: static bool classof(const InputFile *F) { return F->kind() == Base::ObjKind; } ArrayRef getLocalSymbols(); + ArrayRef getGlobalSymbols(); ObjFile(MemoryBufferRef M, StringRef ArchiveName); void parse(llvm::DenseSet &ComdatGroups); diff --git a/contrib/llvm/tools/lld/ELF/SymbolTable.cpp b/contrib/llvm/tools/lld/ELF/SymbolTable.cpp index c3a00bea4aaa..c41e2b2de748 100644 --- a/contrib/llvm/tools/lld/ELF/SymbolTable.cpp +++ b/contrib/llvm/tools/lld/ELF/SymbolTable.cpp @@ -130,7 +130,10 @@ template void SymbolTable::addCombinedLTOObject() { for (InputFile *File : LTO->compile()) { DenseSet DummyGroups; - cast>(File)->parse(DummyGroups); + auto *Obj = cast>(File); + Obj->parse(DummyGroups); + for (Symbol *Sym : Obj->getGlobalSymbols()) + Sym->parseSymbolVersion(); ObjectFiles.push_back(File); } } -- cgit v1.2.3