Remove one of SymbolTable::addRegular function that forwards other addRegular.

So that we have less number of overloaded functions.

llvm-svn: 287745
This commit is contained in:
Rui Ueyama 2016-11-23 06:59:47 +00:00
parent f57e17def0
commit 0cbf749397
4 changed files with 22 additions and 29 deletions

View File

@ -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>::createSymbolBody(const Elf_Sym *Sym) {
}
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>::createSymbolBody(const Elf_Sym *Sym) {
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();
}
}

View File

@ -366,14 +366,6 @@ static void reportDuplicate(SymbolBody *Existing,
print(OldLoc + ": previous definition was here");
}
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,

View File

@ -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);

View File

@ -561,15 +561,13 @@ static Symbol *addOptionalSynthetic(StringRef Name, OutputSectionBase *Sec,
}
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>