Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -726,17 +726,6 @@ } template -static Symbol *addRegular(StringRef Name, SectionBase *Sec, uint64_t Value, - uint8_t StOther = STV_HIDDEN, - uint8_t Binding = STB_WEAK) { - // The linker generated symbols are added as STB_WEAK to allow user defined - // ones to override them. - return Symtab->addRegular(Name, StOther, STT_NOTYPE, Value, - /*Size=*/0, Binding, Sec, - /*File=*/nullptr); -} - -template static DefinedRegular * addOptionalRegular(StringRef Name, SectionBase *Sec, uint64_t Val, uint8_t StOther = STV_HIDDEN, uint8_t Binding = STB_GLOBAL) { @@ -745,8 +734,10 @@ return nullptr; if (S->isInCurrentDSO()) return nullptr; - return cast( - addRegular(Name, Sec, Val, StOther, Binding)->body()); + Symbol *Sym = Symtab->addRegular(Name, StOther, STT_NOTYPE, Val, + /*Size=*/0, Binding, Sec, + /*File=*/nullptr); + return cast(Sym->body()); } // The beginning and the ending of .rel[a].plt section are marked @@ -1251,7 +1242,9 @@ // Even the author of gold doesn't remember why gold behaves that way. // https://sourceware.org/ml/binutils/2002-03/msg00360.html if (InX::DynSymTab) - addRegular("_DYNAMIC", InX::Dynamic, 0); + Symtab->addRegular("_DYNAMIC", STV_HIDDEN, STT_NOTYPE, 0 /*Value*/, + /*Size=*/0, STB_WEAK, InX::Dynamic, + /*File=*/nullptr); // Define __rel[a]_iplt_{start,end} symbols if needed. addRelIpltSymbols();