diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index caae09787660..3d8cbc1a4452 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -236,7 +236,8 @@ template std::pair SymbolTable::insert(StringRef &Name, uint8_t Type, uint8_t Visibility, bool CanOmitFromDynSym, bool HasUnnamedAddr, - bool IsUsedInRegularObj, InputFile *File) { + InputFile *File) { + bool IsUsedInRegularObj = !File || File->kind() == InputFile::ObjectKind; Symbol *S; bool WasInserted; std::tie(S, WasInserted) = insert(Name); @@ -283,8 +284,7 @@ Symbol *SymbolTable::addUndefined(StringRef Name, uint8_t Binding, Symbol *S; bool WasInserted; std::tie(S, WasInserted) = - insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr, - /*IsUsedInRegularObj*/ !File || !isa(File), File); + insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr, File); if (WasInserted) { S->Binding = Binding; replaceBody(S, Name, StOther, Type, File); @@ -349,9 +349,8 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, bool HasUnnamedAddr, InputFile *File) { Symbol *S; bool WasInserted; - std::tie(S, WasInserted) = - insert(N, Type, StOther & 3, /*CanOmitFromDynSym*/ false, HasUnnamedAddr, - !isa(File), File); + std::tie(S, WasInserted) = insert( + N, Type, StOther & 3, /*CanOmitFromDynSym*/ false, HasUnnamedAddr, File); int Cmp = compareDefined(S, WasInserted, Binding); if (Cmp > 0) { S->Binding = Binding; @@ -390,10 +389,10 @@ Symbol *SymbolTable::addRegular(StringRef Name, const Elf_Sym &Sym, InputSectionBase *Section) { Symbol *S; bool WasInserted; - std::tie(S, WasInserted) = insert( - Name, Sym.getType(), Sym.getVisibility(), - /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, - /*IsUsedInRegularObj*/ true, Section ? Section->getFile() : nullptr); + std::tie(S, WasInserted) = + insert(Name, Sym.getType(), Sym.getVisibility(), + /*CanOmitFromDynSym*/ false, /*HasUnnamedAddr*/ false, + Section ? Section->getFile() : nullptr); int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding()); if (Cmp > 0) replaceBody>(S, Name, Sym, Section); @@ -409,7 +408,7 @@ Symbol *SymbolTable::addRegular(StringRef Name, uint8_t Binding, bool WasInserted; std::tie(S, WasInserted) = insert(Name, STT_NOTYPE, StOther & 3, /*CanOmitFromDynSym*/ false, - /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ true, nullptr); + /*HasUnnamedAddr*/ false, nullptr); int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody>(S, Name, StOther); @@ -426,8 +425,7 @@ Symbol *SymbolTable::addSynthetic(StringRef N, bool WasInserted; std::tie(S, WasInserted) = insert(N, STT_NOTYPE, /*Visibility*/ StOther & 0x3, /*CanOmitFromDynSym*/ false, - /*HasUnnamedAddr*/ false, - /*IsUsedInRegularObj*/ true, nullptr); + /*HasUnnamedAddr*/ false, nullptr); int Cmp = compareDefinedNonCommon(S, WasInserted, STB_GLOBAL); if (Cmp > 0) replaceBody>(S, N, Value, Section); @@ -447,7 +445,7 @@ void SymbolTable::addShared(SharedFile *F, StringRef Name, bool WasInserted; std::tie(S, WasInserted) = insert(Name, Sym.getType(), STV_DEFAULT, /*CanOmitFromDynSym*/ true, - /*HasUnnamedAddr*/ false, /*IsUsedInRegularObj*/ false, F); + /*HasUnnamedAddr*/ false, F); // Make sure we preempt DSO symbols with default visibility. if (Sym.getVisibility() == STV_DEFAULT) S->ExportDynamic = true; @@ -466,8 +464,7 @@ Symbol *SymbolTable::addBitcode(StringRef Name, uint8_t Binding, Symbol *S; bool WasInserted; std::tie(S, WasInserted) = - insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr, - /*IsUsedInRegularObj*/ false, F); + insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr, F); int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody>(S, Name, StOther, Type, F); diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index e4911b379ccf..cf4838ce8041 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -95,8 +95,7 @@ private: std::pair insert(StringRef &Name); std::pair insert(StringRef &Name, uint8_t Type, uint8_t Visibility, bool CanOmitFromDynSym, - bool HasUnnamedAddr, bool IsUsedInRegularObj, - InputFile *File); + bool HasUnnamedAddr, InputFile *File); std::string conflictMsg(SymbolBody *Existing, InputFile *NewFile); void reportDuplicate(SymbolBody *Existing, InputFile *NewFile);