[lld] r287745 - Remove one of SymbolTable::addRegular function that forwards other addRegular.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 22 22:59:47 PST 2016
Author: ruiu
Date: Wed Nov 23 00:59:47 2016
New Revision: 287745
URL: http://llvm.org/viewvc/llvm-project?rev=287745&view=rev
Log:
Remove one of SymbolTable::addRegular function that forwards other addRegular.
So that we have less number of overloaded functions.
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/SymbolTable.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=287745&r1=287744&r2=287745&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Nov 23 00:59:47 2016
@@ -438,6 +438,7 @@ template <class ELFT>
SymbolBody *elf::ObjectFile<ELFT>::createSymbolBody(const Elf_Sym *Sym) {
int Binding = Sym->getBinding();
InputSectionBase<ELFT> *Sec = getSection(*Sym);
+
if (Binding == STB_LOCAL) {
if (Sym->getType() == STT_FILE)
SourceFile = check(Sym->getName(this->StringTable));
@@ -452,20 +453,23 @@ SymbolBody *elf::ObjectFile<ELFT>::creat
}
StringRef Name = check(Sym->getName(this->StringTable));
+ uint8_t StOther = Sym->st_other;
+ uint8_t Type = Sym->getType();
+ uintX_t Value = Sym->st_value;
+ uintX_t Size = Sym->st_size;
switch (Sym->st_shndx) {
case SHN_UNDEF:
- return elf::Symtab<ELFT>::X->addUndefined(Name, Binding, Sym->st_other,
- Sym->getType(),
- /*CanOmitFromDynSym*/ false, this)
+ return elf::Symtab<ELFT>::X
+ ->addUndefined(Name, Binding, StOther, Type,
+ /*CanOmitFromDynSym=*/false, this)
->body();
case SHN_COMMON:
- if (Sym->st_value == 0 || Sym->st_value >= UINT32_MAX)
+ if (Value == 0 || Value >= UINT32_MAX)
fatal(getFilename(this) + ": common symbol '" + Name +
- "' has invalid alignment: " + Twine(Sym->st_value));
- return elf::Symtab<ELFT>::X->addCommon(Name, Sym->st_size, Sym->st_value,
- Binding, Sym->st_other,
- Sym->getType(), this)
+ "' has invalid alignment: " + Twine(Value));
+ return elf::Symtab<ELFT>::X
+ ->addCommon(Name, Size, Value, Binding, StOther, Type, this)
->body();
}
@@ -476,12 +480,13 @@ SymbolBody *elf::ObjectFile<ELFT>::creat
case STB_WEAK:
case STB_GNU_UNIQUE:
if (Sec == &InputSection<ELFT>::Discarded)
- return elf::Symtab<ELFT>::X->addUndefined(Name, Binding, Sym->st_other,
- Sym->getType(),
- /*CanOmitFromDynSym*/ false,
- this)
+ return elf::Symtab<ELFT>::X
+ ->addUndefined(Name, Binding, StOther, Type,
+ /*CanOmitFromDynSym=*/false, this)
->body();
- return elf::Symtab<ELFT>::X->addRegular(Name, *Sym, Sec, this)->body();
+ return elf::Symtab<ELFT>::X
+ ->addRegular(Name, StOther, Type, Value, Size, Binding, Sec, this)
+ ->body();
}
}
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=287745&r1=287744&r2=287745&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Nov 23 00:59:47 2016
@@ -367,14 +367,6 @@ static void reportDuplicate(SymbolBody *
}
template <typename ELFT>
-Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, const Elf_Sym &Sym,
- InputSectionBase<ELFT> *Section,
- InputFile *File) {
- return addRegular(Name, Sym.st_other, Sym.getType(), Sym.st_value,
- Sym.st_size, Sym.getBinding(), Section, File);
-}
-
-template <typename ELFT>
Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, uint8_t StOther,
uint8_t Type, uintX_t Value, uintX_t Size,
uint8_t Binding,
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=287745&r1=287744&r2=287745&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Wed Nov 23 00:59:47 2016
@@ -61,8 +61,6 @@ public:
Symbol *addRegular(StringRef Name, uint8_t StOther, uint8_t Type,
uintX_t Value, uintX_t Size, uint8_t Binding,
InputSectionBase<ELFT> *Section, InputFile *File);
- Symbol *addRegular(StringRef Name, const Elf_Sym &Sym,
- InputSectionBase<ELFT> *Section, InputFile *File);
Symbol *addSynthetic(StringRef N, const OutputSectionBase *Section,
uintX_t Value, uint8_t StOther);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=287745&r1=287744&r2=287745&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Nov 23 00:59:47 2016
@@ -561,15 +561,13 @@ static Symbol *addOptionalSynthetic(Stri
}
template <class ELFT>
-static Symbol *addRegular(StringRef Name, InputSectionBase<ELFT> *IS,
+static Symbol *addRegular(StringRef Name, InputSectionBase<ELFT> *Sec,
typename ELFT::uint Value) {
- typename ELFT::Sym LocalHidden = {};
// The linker generated symbols are added as STB_WEAK to allow user defined
// ones to override them.
- LocalHidden.setBindingAndType(STB_WEAK, STT_NOTYPE);
- LocalHidden.setVisibility(STV_HIDDEN);
- LocalHidden.st_value = Value;
- return Symtab<ELFT>::X->addRegular(Name, LocalHidden, IS, nullptr);
+ return Symtab<ELFT>::X->addRegular(Name, STV_HIDDEN, STT_NOTYPE, Value,
+ /*Size=*/0, STB_WEAK, Sec,
+ /*File=*/nullptr);
}
template <class ELFT>
More information about the llvm-commits
mailing list