diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1302,7 +1302,7 @@ Defined New(&F, Name, Binding, Visibility, Type, 0, 0, nullptr); if (CanOmitFromDynSym) New.ExportDynamic = false; - return Symtab->addBitcode(&New); + return Symtab->addDefined(&New); } template diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -45,13 +45,12 @@ ArrayRef getSymbols() const { return SymVector; } - Symbol *addUndefined(Undefined *New); - Symbol *addDefined(Defined *New); - void addShared(SharedSymbol *New); - void addLazyArchive(LazyArchive *New); - void addLazyObject(LazyObject *New); - Symbol *addBitcode(Defined *New); Symbol *addCommon(CommonSymbol *New); + Symbol *addDefined(Defined *New); + Symbol *addLazyArchive(LazyArchive *New); + Symbol *addLazyObject(LazyObject *New); + Symbol *addShared(SharedSymbol *New); + Symbol *addUndefined(Undefined *New); Symbol *insert(Symbol *New); void mergeProperties(Symbol *Old, Symbol *New); @@ -70,7 +69,7 @@ llvm::DenseMap SoNames; private: - template void addLazy(LazyT *New); + template Symbol *addLazy(LazyT *New); std::vector findByVersion(SymbolVersion Ver); std::vector findAllByVersion(SymbolVersion Ver); diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -382,7 +382,7 @@ return Old; } -void SymbolTable::addShared(SharedSymbol *New) { +Symbol *SymbolTable::addShared(SharedSymbol *New) { Symbol *Old = insert(New); mergeProperties(Old, New); @@ -392,7 +392,7 @@ if (Old->isPlaceholder()) { replaceSymbol(Old, New); - return; + return Old; } if (Old->Visibility == STV_DEFAULT && (Old->isUndefined() || Old->isLazy())) { @@ -402,22 +402,6 @@ replaceSymbol(Old, New); Old->Binding = Binding; } -} - -Symbol *SymbolTable::addBitcode(Defined *New) { - Symbol *Old = insert(New); - mergeProperties(Old, New); - - if (Old->isPlaceholder()) { - replaceSymbol(Old, New); - return Old; - } - - int Cmp = compare(Old, New); - if (Cmp > 0) - replaceSymbol(Old, New); - else if (Cmp == 0) - reportDuplicate(Old, New->File, nullptr, 0); return Old; } @@ -430,17 +414,17 @@ return SymVector[It->second]; } -template void SymbolTable::addLazy(LazyT *New) { +template Symbol *SymbolTable::addLazy(LazyT *New) { Symbol *Old = insert(New); mergeProperties(Old, New); if (Old->isPlaceholder()) { replaceSymbol(Old, New); - return; + return Old; } if (!Old->isUndefined()) - return; + return Old; // An undefined weak will not fetch archive members. See comment on Lazy in // Symbols.h for the details. @@ -449,16 +433,17 @@ replaceSymbol(Old, New); Old->Type = Type; Old->Binding = STB_WEAK; - return; + return Old; } if (InputFile *F = New->fetch()) parseFile(F); + return Old; } -void SymbolTable::addLazyArchive(LazyArchive *New) { addLazy(New); } +Symbol *SymbolTable::addLazyArchive(LazyArchive *New) { return addLazy(New); } -void SymbolTable::addLazyObject(LazyObject *New) { addLazy(New); } +Symbol *SymbolTable::addLazyObject(LazyObject *New) { return addLazy(New); } void SymbolTable::fetchLazy(Symbol *Sym) { if (auto *S = dyn_cast(Sym)) {