From 5ceeb60c6ebc9d1193d8af9f336b6cce5ca9e1d8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 26 Oct 2016 20:57:14 +0000 Subject: [PATCH] Have on addRegular forward to another. NFC. Another step in making it easier to create symbols without an ELf_Sym. llvm-svn: 285241 --- lld/ELF/SymbolTable.cpp | 27 ++++++++++++++------------- lld/ELF/SymbolTable.h | 4 ++++ lld/ELF/Symbols.h | 11 +++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index a017df3..106a648 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -374,14 +374,24 @@ void SymbolTable::reportDuplicate(SymbolBody *Existing, template Symbol *SymbolTable::addRegular(StringRef Name, const Elf_Sym &Sym, InputSectionBase *Section) { + return addRegular(Name, Sym.st_other, Sym.getType(), Sym.st_value, + Sym.st_size, Sym.getBinding(), Section); +} + +template +Symbol *SymbolTable::addRegular(StringRef Name, uint8_t StOther, + uint8_t Type, uintX_t Value, uintX_t Size, + uint8_t Binding, + InputSectionBase *Section) { Symbol *S; bool WasInserted; - std::tie(S, WasInserted) = insert(Name, Sym.getType(), Sym.getVisibility(), + std::tie(S, WasInserted) = insert(Name, Type, StOther & 3, /*CanOmitFromDynSym*/ false, Section ? Section->getFile() : nullptr); - int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding()); + int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) - replaceBody>(S, Name, Sym, Section); + replaceBody>(S, Name, StOther, Type, Value, Size, + Section); else if (Cmp == 0) reportDuplicate(S->body(), Section->getFile()); return S; @@ -390,16 +400,7 @@ Symbol *SymbolTable::addRegular(StringRef Name, const Elf_Sym &Sym, template Symbol *SymbolTable::addRegular(StringRef Name, uint8_t Binding, uint8_t StOther) { - Symbol *S; - bool WasInserted; - std::tie(S, WasInserted) = insert(Name, STT_NOTYPE, StOther & 3, - /*CanOmitFromDynSym*/ false, nullptr); - int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); - if (Cmp > 0) - replaceBody>(S, Name, StOther); - else if (Cmp == 0) - reportDuplicate(S->body(), nullptr); - return S; + return addRegular(Name, StOther, STT_NOTYPE, 0, 0, Binding, nullptr); } template diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index f95ff12..7230313 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -63,6 +63,10 @@ public: Symbol *addUndefined(StringRef Name, uint8_t Binding, uint8_t StOther, uint8_t Type, bool CanOmitFromDynSym, InputFile *File); + Symbol *addRegular(StringRef Name, uint8_t StOther, uint8_t Type, + uintX_t Value, uintX_t Size, uint8_t Binding, + InputSectionBase *Section); + Symbol *addRegular(StringRef Name, const Elf_Sym &Sym, InputSectionBase *Section); Symbol *addRegular(StringRef Name, uint8_t Binding, uint8_t StOther); diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 23c38d3..a00c800 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -194,16 +194,11 @@ public: this->File = File; } - DefinedRegular(StringRef Name, const Elf_Sym &Sym, - InputSectionBase *Section) - : DefinedRegular(Name, Sym.st_other, Sym.getType(), Sym.st_value, - Sym.st_size, Section, + DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, uintX_t Value, + uintX_t Size, InputSectionBase *Section) + : DefinedRegular(Name, StOther, Type, Value, Size, Section, Section ? Section->getFile() : nullptr) {} - DefinedRegular(StringRef Name, uint8_t StOther) - : DefinedRegular(Name, StOther, llvm::ELF::STT_NOTYPE, 0, 0, - NullInputSection, nullptr) {} - DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, BitcodeFile *F) : DefinedRegular(Name, StOther, Type, 0, 0, NullInputSection, F) {} -- 2.7.4