From owner-svn-src-vendor@freebsd.org Mon Sep 2 17:49:34 2019 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DA2CDE42BF; Mon, 2 Sep 2019 17:49:34 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46MczL4wwmz45Wc; Mon, 2 Sep 2019 17:49:34 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43EF91DB9F; Mon, 2 Sep 2019 17:49:34 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x82HnYej020017; Mon, 2 Sep 2019 17:49:34 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x82HnU1o020001; Mon, 2 Sep 2019 17:49:30 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201909021749.x82HnU1o020001@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 2 Sep 2019 17:49:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r351718 - in vendor/lld/dist-release_90: . COFF ELF ELF/Arch docs X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in vendor/lld/dist-release_90: . COFF ELF ELF/Arch docs X-SVN-Commit-Revision: 351718 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Sep 2019 17:49:35 -0000 Author: dim Date: Mon Sep 2 17:49:30 2019 New Revision: 351718 URL: https://svnweb.freebsd.org/changeset/base/351718 Log: Vendor import of lld release_90 branch r370514: https://llvm.org/svn/llvm-project/lld/branches/release_90@370514 Modified: vendor/lld/dist-release_90/CMakeLists.txt vendor/lld/dist-release_90/COFF/Config.h vendor/lld/dist-release_90/COFF/Driver.cpp vendor/lld/dist-release_90/COFF/Driver.h vendor/lld/dist-release_90/COFF/InputFiles.cpp vendor/lld/dist-release_90/COFF/InputFiles.h vendor/lld/dist-release_90/COFF/SymbolTable.cpp vendor/lld/dist-release_90/COFF/SymbolTable.h vendor/lld/dist-release_90/COFF/Symbols.cpp vendor/lld/dist-release_90/COFF/Symbols.h vendor/lld/dist-release_90/COFF/Writer.cpp vendor/lld/dist-release_90/ELF/Arch/PPC.cpp vendor/lld/dist-release_90/ELF/Arch/PPC64.cpp vendor/lld/dist-release_90/ELF/InputFiles.cpp vendor/lld/dist-release_90/ELF/Symbols.cpp vendor/lld/dist-release_90/ELF/Symbols.h vendor/lld/dist-release_90/docs/ReleaseNotes.rst Modified: vendor/lld/dist-release_90/CMakeLists.txt ============================================================================== --- vendor/lld/dist-release_90/CMakeLists.txt Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/CMakeLists.txt Mon Sep 2 17:49:30 2019 (r351718) @@ -56,7 +56,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) include(HandleLLVMOptions) if(LLVM_INCLUDE_TESTS) - set(Python_ADDITIONAL_VERSIONS 2.7) include(FindPythonInterp) if(NOT PYTHONINTERP_FOUND) message(FATAL_ERROR Modified: vendor/lld/dist-release_90/COFF/Config.h ============================================================================== --- vendor/lld/dist-release_90/COFF/Config.h Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/Config.h Mon Sep 2 17:49:30 2019 (r351718) @@ -189,6 +189,7 @@ struct Configuration { // Used for /thinlto-object-suffix-replace: std::pair thinLTOObjectSuffixReplace; + uint64_t align = 4096; uint64_t imageBase = -1; uint64_t fileAlign = 512; uint64_t stackReserve = 1024 * 1024; Modified: vendor/lld/dist-release_90/COFF/Driver.cpp ============================================================================== --- vendor/lld/dist-release_90/COFF/Driver.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/Driver.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -36,6 +36,7 @@ #include "llvm/Option/Option.h" #include "llvm/Support/Debug.h" #include "llvm/Support/LEB128.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/TarWriter.h" @@ -270,13 +271,12 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb } void LinkerDriver::enqueueArchiveMember(const Archive::Child &c, - StringRef symName, + const Archive::Symbol &sym, StringRef parentName) { - auto reportBufferError = [=](Error &&e, - StringRef childName) { + auto reportBufferError = [=](Error &&e, StringRef childName) { fatal("could not get the buffer for the member defining symbol " + - symName + ": " + parentName + "(" + childName + "): " + + toCOFFString(sym) + ": " + parentName + "(" + childName + "): " + toString(std::move(e))); }; @@ -287,7 +287,8 @@ void LinkerDriver::enqueueArchiveMember(const Archive: reportBufferError(mbOrErr.takeError(), check(c.getFullName())); MemoryBufferRef mb = mbOrErr.get(); enqueueTask([=]() { - driver->addArchiveBuffer(mb, symName, parentName, offsetInArchive); + driver->addArchiveBuffer(mb, toCOFFString(sym), parentName, + offsetInArchive); }); return; } @@ -295,15 +296,16 @@ void LinkerDriver::enqueueArchiveMember(const Archive: std::string childName = CHECK( c.getFullName(), "could not get the filename for the member defining symbol " + - symName); + toCOFFString(sym)); auto future = std::make_shared>( createFutureForFile(childName)); enqueueTask([=]() { auto mbOrErr = future->get(); if (mbOrErr.second) reportBufferError(errorCodeToError(mbOrErr.second), childName); - driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)), symName, - parentName, /* OffsetInArchive */ 0); + driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)), + toCOFFString(sym), parentName, + /*OffsetInArchive=*/0); }); } @@ -1053,6 +1055,12 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt:: }); } +static const char *libcallRoutineNames[] = { +#define HANDLE_LIBCALL(code, name) name, +#include "llvm/IR/RuntimeLibcalls.def" +#undef HANDLE_LIBCALL +}; + void LinkerDriver::link(ArrayRef argsArr) { // Needed for LTO. InitializeAllTargetInfos(); @@ -1421,6 +1429,13 @@ void LinkerDriver::link(ArrayRef argsArr for (auto *arg : args.filtered(OPT_section)) parseSection(arg->getValue()); + // Handle /align + if (auto *arg = args.getLastArg(OPT_align)) { + parseNumbers(arg->getValue(), &config->align); + if (!isPowerOf2_64(config->align)) + error("/align: not a power of two: " + StringRef(arg->getValue())); + } + // Handle /aligncomm for (auto *arg : args.filtered(OPT_aligncomm)) parseAligncomm(arg->getValue()); @@ -1747,6 +1762,15 @@ void LinkerDriver::link(ArrayRef argsArr if (!u->weakAlias) u->weakAlias = symtab->addUndefined(to); } + + // If any inputs are bitcode files, the LTO code generator may create + // references to library functions that are not explicit in the bitcode + // file's symbol table. If any of those library functions are defined in a + // bitcode file in an archive member, we need to arrange to use LTO to + // compile those archive members by adding them to the link beforehand. + if (!BitcodeFile::instances.empty()) + for (const char *s : libcallRoutineNames) + symtab->addLibcall(s); // Windows specific -- if __load_config_used can be resolved, resolve it. if (symtab->findUnderscore("_load_config_used")) Modified: vendor/lld/dist-release_90/COFF/Driver.h ============================================================================== --- vendor/lld/dist-release_90/COFF/Driver.h Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/Driver.h Mon Sep 2 17:49:30 2019 (r351718) @@ -72,7 +72,7 @@ class LinkerDriver { (public) void parseDirectives(InputFile *file); // Used by ArchiveFile to enqueue members. - void enqueueArchiveMember(const Archive::Child &c, StringRef symName, + void enqueueArchiveMember(const Archive::Child &c, const Archive::Symbol &sym, StringRef parentName); MemoryBufferRef takeBuffer(std::unique_ptr mb); Modified: vendor/lld/dist-release_90/COFF/InputFiles.cpp ============================================================================== --- vendor/lld/dist-release_90/COFF/InputFiles.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/InputFiles.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -85,16 +85,16 @@ void ArchiveFile::parse() { } // Returns a buffer pointing to a member file containing a given symbol. -void ArchiveFile::addMember(const Archive::Symbol *sym) { +void ArchiveFile::addMember(const Archive::Symbol &sym) { const Archive::Child &c = - CHECK(sym->getMember(), - "could not get the member for symbol " + sym->getName()); + CHECK(sym.getMember(), + "could not get the member for symbol " + toCOFFString(sym)); // Return an empty buffer if we have already returned the same buffer. if (!seen.insert(c.getChildOffset()).second) return; - driver->enqueueArchiveMember(c, sym->getName(), getName()); + driver->enqueueArchiveMember(c, sym, getName()); } std::vector getArchiveMembers(Archive *file) { Modified: vendor/lld/dist-release_90/COFF/InputFiles.h ============================================================================== --- vendor/lld/dist-release_90/COFF/InputFiles.h Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/InputFiles.h Mon Sep 2 17:49:30 2019 (r351718) @@ -96,7 +96,7 @@ class ArchiveFile : public InputFile { (public) // Enqueues an archive member load for the given symbol. If we've already // enqueued a load for the same archive member, this function does nothing, // which ensures that we don't load the same member more than once. - void addMember(const Archive::Symbol *sym); + void addMember(const Archive::Symbol &sym); private: std::unique_ptr file; Modified: vendor/lld/dist-release_90/COFF/SymbolTable.cpp ============================================================================== --- vendor/lld/dist-release_90/COFF/SymbolTable.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/SymbolTable.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -179,7 +179,7 @@ void SymbolTable::loadMinGWAutomaticImports() { log("Loading lazy " + l->getName() + " from " + l->file->getName() + " for automatic import"); l->pendingArchiveLoad = true; - l->file->addMember(&l->sym); + l->file->addMember(l->sym); } } @@ -363,13 +363,13 @@ Symbol *SymbolTable::addUndefined(StringRef name, Inpu if (auto *l = dyn_cast(s)) { if (!s->pendingArchiveLoad) { s->pendingArchiveLoad = true; - l->file->addMember(&l->sym); + l->file->addMember(l->sym); } } return s; } -void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol sym) { +void SymbolTable::addLazy(ArchiveFile *f, const Archive::Symbol &sym) { StringRef name = sym.getName(); Symbol *s; bool wasInserted; @@ -382,7 +382,7 @@ void SymbolTable::addLazy(ArchiveFile *f, const Archiv if (!u || u->weakAlias || s->pendingArchiveLoad) return; s->pendingArchiveLoad = true; - f->addMember(&sym); + f->addMember(sym); } void SymbolTable::reportDuplicate(Symbol *existing, InputFile *newFile) { @@ -503,6 +503,18 @@ Symbol *SymbolTable::addImportThunk(StringRef name, De reportDuplicate(s, id->file); return nullptr; +} + +void SymbolTable::addLibcall(StringRef name) { + Symbol *sym = findUnderscore(name); + if (!sym) + return; + + if (Lazy *l = dyn_cast(sym)) { + MemoryBufferRef mb = l->getMemberBuffer(); + if (identify_magic(mb.getBuffer()) == llvm::file_magic::bitcode) + addUndefined(sym->getName()); + } } std::vector SymbolTable::getChunks() { Modified: vendor/lld/dist-release_90/COFF/SymbolTable.h ============================================================================== --- vendor/lld/dist-release_90/COFF/SymbolTable.h Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/SymbolTable.h Mon Sep 2 17:49:30 2019 (r351718) @@ -83,7 +83,7 @@ class SymbolTable { (public) Symbol *addAbsolute(StringRef n, uint64_t va); Symbol *addUndefined(StringRef name, InputFile *f, bool isWeakAlias); - void addLazy(ArchiveFile *f, const Archive::Symbol sym); + void addLazy(ArchiveFile *f, const Archive::Symbol &sym); Symbol *addAbsolute(StringRef n, COFFSymbolRef s); Symbol *addRegular(InputFile *f, StringRef n, const llvm::object::coff_symbol_generic *s = nullptr, @@ -97,6 +97,7 @@ class SymbolTable { (public) Symbol *addImportData(StringRef n, ImportFile *f); Symbol *addImportThunk(StringRef name, DefinedImportData *s, uint16_t machine); + void addLibcall(StringRef name); void reportDuplicate(Symbol *existing, InputFile *newFile); Modified: vendor/lld/dist-release_90/COFF/Symbols.cpp ============================================================================== --- vendor/lld/dist-release_90/COFF/Symbols.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/Symbols.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -20,18 +20,23 @@ using namespace llvm::object; using namespace lld::coff; +namespace lld { + static_assert(sizeof(SymbolUnion) <= 48, "symbols should be optimized for memory usage"); // Returns a symbol name for an error message. -std::string lld::toString(coff::Symbol &b) { +static std::string demangle(StringRef symName) { if (config->demangle) - if (Optional s = lld::demangleMSVC(b.getName())) + if (Optional s = demangleMSVC(symName)) return *s; - return b.getName(); + return symName; } +std::string toString(coff::Symbol &b) { return demangle(b.getName()); } +std::string toCOFFString(const Archive::Symbol &b) { + return demangle(b.getName()); +} -namespace lld { namespace coff { StringRef Symbol::getName() { @@ -112,6 +117,15 @@ Defined *Undefined::getWeakAlias() { if (auto *d = dyn_cast(a)) return d; return nullptr; +} + +MemoryBufferRef Lazy::getMemberBuffer() { + Archive::Child c = + CHECK(sym.getMember(), + "could not get the member for symbol " + toCOFFString(sym)); + return CHECK(c.getMemoryBufferRef(), + "could not get the buffer for the member defining symbol " + + toCOFFString(sym)); } } // namespace coff } // namespace lld Modified: vendor/lld/dist-release_90/COFF/Symbols.h ============================================================================== --- vendor/lld/dist-release_90/COFF/Symbols.h Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/Symbols.h Mon Sep 2 17:49:30 2019 (r351718) @@ -21,6 +21,14 @@ #include namespace lld { + +std::string toString(coff::Symbol &b); + +// There are two different ways to convert an Archive::Symbol to a string: +// One for Microsoft name mangling and one for Itanium name mangling. +// Call the functions toCOFFString and toELFString, not just toString. +std::string toCOFFString(const coff::Archive::Symbol &b); + namespace coff { using llvm::object::Archive; @@ -257,6 +265,8 @@ class Lazy : public Symbol { (public) static bool classof(const Symbol *s) { return s->kind() == LazyKind; } + MemoryBufferRef getMemberBuffer(); + ArchiveFile *file; private: @@ -429,7 +439,6 @@ void replaceSymbol(Symbol *s, ArgT &&... arg) { } } // namespace coff -std::string toString(coff::Symbol &b); } // namespace lld #endif Modified: vendor/lld/dist-release_90/COFF/Writer.cpp ============================================================================== --- vendor/lld/dist-release_90/COFF/Writer.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/COFF/Writer.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -626,6 +626,9 @@ void Writer::run() { writeMapFile(outputSections); + if (errorCount()) + return; + ScopedTimer t2(diskCommitTimer); if (auto e = buffer->commit()) fatal("failed to write the output file: " + toString(std::move(e))); @@ -1205,9 +1208,11 @@ void Writer::assignAddresses() { sizeOfHeaders += config->is64() ? sizeof(pe32plus_header) : sizeof(pe32_header); sizeOfHeaders = alignTo(sizeOfHeaders, config->fileAlign); - uint64_t rva = pageSize; // The first page is kept unmapped. fileSize = sizeOfHeaders; + // The first page is kept unmapped. + uint64_t rva = alignTo(sizeOfHeaders, config->align); + for (OutputSection *sec : outputSections) { if (sec == relocSec) addBaserels(); @@ -1237,10 +1242,10 @@ void Writer::assignAddresses() { sec->header.SizeOfRawData = rawSize; if (rawSize != 0) sec->header.PointerToRawData = fileSize; - rva += alignTo(virtualSize, pageSize); + rva += alignTo(virtualSize, config->align); fileSize += alignTo(rawSize, config->fileAlign); } - sizeOfImage = alignTo(rva, pageSize); + sizeOfImage = alignTo(rva, config->align); // Assign addresses to sections in MergeChunks. for (MergeChunk *mc : MergeChunk::instances) @@ -1309,7 +1314,7 @@ template void Writer::writeHeade pe->MinorLinkerVersion = 0; pe->ImageBase = config->imageBase; - pe->SectionAlignment = pageSize; + pe->SectionAlignment = config->align; pe->FileAlignment = config->fileAlign; pe->MajorImageVersion = config->majorImageVersion; pe->MinorImageVersion = config->minorImageVersion; Modified: vendor/lld/dist-release_90/ELF/Arch/PPC.cpp ============================================================================== --- vendor/lld/dist-release_90/ELF/Arch/PPC.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/ELF/Arch/PPC.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -190,6 +190,13 @@ bool PPC::inBranchRange(RelType type, uint64_t src, ui RelExpr PPC::getRelExpr(RelType type, const Symbol &s, const uint8_t *loc) const { switch (type) { + case R_PPC_NONE: + return R_NONE; + case R_PPC_ADDR16_HA: + case R_PPC_ADDR16_HI: + case R_PPC_ADDR16_LO: + case R_PPC_ADDR32: + return R_ABS; case R_PPC_DTPREL16: case R_PPC_DTPREL16_HA: case R_PPC_DTPREL16_HI: @@ -227,7 +234,9 @@ RelExpr PPC::getRelExpr(RelType type, const Symbol &s, case R_PPC_TPREL16_HI: return R_TLS; default: - return R_ABS; + error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + + ") against symbol " + toString(s)); + return R_NONE; } } @@ -319,7 +328,7 @@ void PPC::relocateOne(uint8_t *loc, RelType type, uint break; } default: - error(getErrorLocation(loc) + "unrecognized relocation " + toString(type)); + llvm_unreachable("unknown relocation"); } } Modified: vendor/lld/dist-release_90/ELF/Arch/PPC64.cpp ============================================================================== --- vendor/lld/dist-release_90/ELF/Arch/PPC64.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/ELF/Arch/PPC64.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -532,6 +532,21 @@ void PPC64::relaxTlsIeToLe(uint8_t *loc, RelType type, RelExpr PPC64::getRelExpr(RelType type, const Symbol &s, const uint8_t *loc) const { switch (type) { + case R_PPC64_NONE: + return R_NONE; + case R_PPC64_ADDR16: + case R_PPC64_ADDR16_DS: + case R_PPC64_ADDR16_HA: + case R_PPC64_ADDR16_HI: + case R_PPC64_ADDR16_HIGHER: + case R_PPC64_ADDR16_HIGHERA: + case R_PPC64_ADDR16_HIGHEST: + case R_PPC64_ADDR16_HIGHESTA: + case R_PPC64_ADDR16_LO: + case R_PPC64_ADDR16_LO_DS: + case R_PPC64_ADDR32: + case R_PPC64_ADDR64: + return R_ABS; case R_PPC64_GOT16: case R_PPC64_GOT16_DS: case R_PPC64_GOT16_HA: @@ -554,6 +569,7 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol & return R_PPC64_CALL_PLT; case R_PPC64_REL16_LO: case R_PPC64_REL16_HA: + case R_PPC64_REL16_HI: case R_PPC64_REL32: case R_PPC64_REL64: return R_PC; @@ -607,7 +623,9 @@ RelExpr PPC64::getRelExpr(RelType type, const Symbol & case R_PPC64_TLS: return R_TLSIE_HINT; default: - return R_ABS; + error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + + ") against symbol " + toString(s)); + return R_NONE; } } @@ -870,7 +888,7 @@ void PPC64::relocateOne(uint8_t *loc, RelType type, ui write64(loc, val - dynamicThreadPointerOffset); break; default: - error(getErrorLocation(loc) + "unrecognized relocation " + toString(type)); + llvm_unreachable("unknown relocation"); } } Modified: vendor/lld/dist-release_90/ELF/InputFiles.cpp ============================================================================== --- vendor/lld/dist-release_90/ELF/InputFiles.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/ELF/InputFiles.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -1144,7 +1144,7 @@ void ArchiveFile::fetch(const Archive::Symbol &sym) { Archive::Child c = CHECK(sym.getMember(), toString(this) + ": could not get the member for symbol " + - sym.getName()); + toELFString(sym)); if (!seen.insert(c.getChildOffset()).second) return; @@ -1153,7 +1153,7 @@ void ArchiveFile::fetch(const Archive::Symbol &sym) { CHECK(c.getMemoryBufferRef(), toString(this) + ": could not get the buffer for the member defining symbol " + - sym.getName()); + toELFString(sym)); if (tar && c.getParent()->isThin()) tar->append(relativeToRoot(CHECK(c.getFullName(), this)), mb.getBuffer()); Modified: vendor/lld/dist-release_90/ELF/Symbols.cpp ============================================================================== --- vendor/lld/dist-release_90/ELF/Symbols.cpp Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/ELF/Symbols.cpp Mon Sep 2 17:49:30 2019 (r351718) @@ -42,6 +42,20 @@ Defined *ElfSym::relaIpltEnd; Defined *ElfSym::riscvGlobalPointer; Defined *ElfSym::tlsModuleBase; +// Returns a symbol for an error message. +static std::string demangle(StringRef symName) { + if (config->demangle) + if (Optional s = demangleItanium(symName)) + return *s; + return symName; +} +namespace lld { +std::string toString(const Symbol &b) { return demangle(b.getName()); } +std::string toELFString(const Archive::Symbol &b) { + return demangle(b.getName()); +} +} // namespace lld + static uint64_t getSymVA(const Symbol &sym, int64_t &addend) { switch (sym.kind()) { case Symbol::DefinedKind: { @@ -250,12 +264,13 @@ void Symbol::fetch() const { } MemoryBufferRef LazyArchive::getMemberBuffer() { - Archive::Child c = CHECK( - sym.getMember(), "could not get the member for symbol " + sym.getName()); + Archive::Child c = + CHECK(sym.getMember(), + "could not get the member for symbol " + toELFString(sym)); return CHECK(c.getMemoryBufferRef(), "could not get the buffer for the member defining symbol " + - sym.getName()); + toELFString(sym)); } uint8_t Symbol::computeBinding() const { @@ -329,14 +344,6 @@ void elf::maybeWarnUnorderableSymbol(const Symbol *sym report(": unable to order synthetic symbol: "); else if (d && !d->section->repl->isLive()) report(": unable to order discarded symbol: "); -} - -// Returns a symbol for an error message. -std::string lld::toString(const Symbol &b) { - if (config->demangle) - if (Optional s = demangleItanium(b.getName())) - return *s; - return b.getName(); } static uint8_t getMinVisibility(uint8_t va, uint8_t vb) { Modified: vendor/lld/dist-release_90/ELF/Symbols.h ============================================================================== --- vendor/lld/dist-release_90/ELF/Symbols.h Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/ELF/Symbols.h Mon Sep 2 17:49:30 2019 (r351718) @@ -33,7 +33,11 @@ class Undefined; } // namespace elf std::string toString(const elf::Symbol &); -std::string toString(const elf::InputFile *); + +// There are two different ways to convert an Archive::Symbol to a string: +// One for Microsoft name mangling and one for Itanium name mangling. +// Call the functions toCOFFString and toELFString, not just toString. +std::string toELFString(const elf::Archive::Symbol &); namespace elf { Modified: vendor/lld/dist-release_90/docs/ReleaseNotes.rst ============================================================================== --- vendor/lld/dist-release_90/docs/ReleaseNotes.rst Mon Sep 2 17:49:27 2019 (r351717) +++ vendor/lld/dist-release_90/docs/ReleaseNotes.rst Mon Sep 2 17:49:30 2019 (r351718) @@ -5,11 +5,6 @@ lld 9.0.0 Release Notes .. contents:: :local: -.. warning:: - These are in-progress notes for the upcoming LLVM 9.0.0 release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ @@ -37,8 +32,6 @@ ELF Improvements into corresponding PT_MIPS_REGINFO, PT_MIPS_OPTIONS, and PT_MIPS_ABIFLAGS segments. -* ... - COFF Improvements ----------------- @@ -51,6 +44,12 @@ COFF Improvements input files define resources with the same type, name, and language. This can be demoted to a warning using ``/force:multipleres``. +* lld-link now rejects more than one resource obj input files, matching + link.exe. Previously, lld-link would silently ignore all but one. + If you hit this: Don't pass resource obj files to the linker, instead pass + res files to the linker directly. Don't put res files in static libraries, + pass them on the command line. + * Having more than two ``/natvis:`` now works correctly; it used to not work for larger binaries before. @@ -70,8 +69,6 @@ COFF Improvements * The generated thunks for delayimports now share the majority of code among thunks, significantly reducing the overhead of using delayimport -* ... - MinGW Improvements ------------------ @@ -89,13 +86,3 @@ MinGW Improvements name, with the new option ``-pdb=`` with an empty value to the option. (The old existing syntax ``-pdb `` was more cumbersome to use with an empty parameter value.) - -MachO Improvements ------------------- - -* Item 1. - -WebAssembly Improvements ------------------------- - -* ...