From 3460cdd4404504a2e4d5e7e79c3c8f715c64540f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 24 Apr 2017 21:44:20 +0000 Subject: [PATCH] Remove DefaultSoName. We can just use the existing SoName member variable. It now initially contains what was in DefaultSoName and is modified if the .so has an actual soname. llvm-svn: 301259 --- lld/ELF/Driver.cpp | 6 ++---- lld/ELF/InputFiles.cpp | 42 ++++++++++++++++++++++++++---------------- lld/ELF/InputFiles.h | 12 ++++-------- lld/ELF/SymbolTable.cpp | 2 +- lld/ELF/SyntheticSections.cpp | 4 ++-- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 93924e4..2d1a935 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -184,8 +184,6 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) { error("attempted static link of dynamic object " + Path); return; } - Files.push_back(createSharedFile(MBRef)); - // DSOs usually have DT_SONAME tags in their ELF headers, and the // sonames are used to identify DSOs. But if they are missing, // they are identified by filenames. We don't know whether the new @@ -196,8 +194,8 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) { // If a file was specified by -lfoo, the directory part is not // significant, as a user did not specify it. This behavior is // compatible with GNU. - Files.back()->DefaultSoName = - WithLOption ? sys::path::filename(Path) : Path; + Files.push_back(createSharedFile( + MBRef, WithLOption ? sys::path::filename(Path) : Path)); return; default: if (InLib) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index d651fbc..d99f71e 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -608,8 +608,9 @@ ArchiveFile::getMember(const Archive::Symbol *Sym) { } template -SharedFile::SharedFile(MemoryBufferRef M) - : ELFFileBase(Base::SharedKind, M), AsNeeded(Config->AsNeeded) {} +SharedFile::SharedFile(MemoryBufferRef M, StringRef DefaultSoName) + : ELFFileBase(Base::SharedKind, M), SoName(DefaultSoName), + AsNeeded(Config->AsNeeded) {} template const typename ELFT::Shdr * @@ -619,12 +620,6 @@ SharedFile::getSection(const Elf_Sym &Sym) const { toString(this)); } -template StringRef SharedFile::getSoName() const { - if (SoName.empty()) - return this->DefaultSoName; - return SoName; -} - // Partially parse the shared object file so that we can call // getSoName on this object. template void SharedFile::parseSoName() { @@ -867,8 +862,23 @@ void BitcodeFile::parse(DenseSet &ComdatGroups) { Symbols.push_back(createBitcodeSymbol(KeptComdats, ObjSym, this)); } +// Small bit of template meta programming to handle the SharedFile constructor +// being the only one with a DefaultSoName parameter. +template