De-template SymbolTable::addShared.

Because of r357925, this member function doesn't have to be a
template of ELFT.

llvm-svn: 357982
This commit is contained in:
Rui Ueyama 2019-04-09 08:52:00 +00:00
parent 30d3c58b81
commit f432fa6eee
3 changed files with 17 additions and 28 deletions

View File

@ -1059,7 +1059,8 @@ template <class ELFT> void SharedFile::parse() {
uint64_t Alignment = getAlignment<ELFT>(Sections, Sym);
if (!(Versyms[I] & VERSYM_HIDDEN))
Symtab->addShared<ELFT>(Name, *this, Sym, Alignment, Idx);
Symtab->addShared(Name, Sym.getBinding(), Sym.st_other, Sym.getType(),
Sym.st_value, Sym.st_size, Alignment, Idx, this);
// Also add the symbol with the versioned name to handle undefined symbols
// with explicit versions.
@ -1078,7 +1079,9 @@ template <class ELFT> void SharedFile::parse() {
reinterpret_cast<const Elf_Verdef *>(Verdefs[Idx])->getAux()->vda_name;
VersionedNameBuffer.clear();
Name = (Name + "@" + VerName).toStringRef(VersionedNameBuffer);
Symtab->addShared<ELFT>(Saver.save(Name), *this, Sym, Alignment, Idx);
Symtab->addShared(Saver.save(Name), Sym.getBinding(), Sym.st_other,
Sym.getType(), Sym.st_value, Sym.st_size, Alignment, Idx,
this);
}
}

View File

@ -467,31 +467,30 @@ Defined *SymbolTable::addDefined(StringRef Name, uint8_t StOther, uint8_t Type,
return cast<Defined>(S);
}
template <typename ELFT>
void SymbolTable::addShared(StringRef Name, SharedFile &File,
const typename ELFT::Sym &Sym, uint32_t Alignment,
uint32_t VerdefIndex) {
void SymbolTable::addShared(StringRef Name, uint8_t Binding, uint8_t StOther,
uint8_t Type, uint64_t Value, uint64_t Size,
uint32_t Alignment, uint32_t VerdefIndex,
InputFile *File) {
// DSO symbols do not affect visibility in the output, so we pass STV_DEFAULT
// as the visibility, which will leave the visibility in the symbol table
// unchanged.
Symbol *S;
bool WasInserted;
std::tie(S, WasInserted) = insert(Name, STV_DEFAULT,
/*CanOmitFromDynSym*/ true, &File);
/*CanOmitFromDynSym*/ true, File);
// Make sure we preempt DSO symbols with default visibility.
if (Sym.getVisibility() == STV_DEFAULT)
if (getVisibility(StOther) == STV_DEFAULT)
S->ExportDynamic = true;
// An undefined symbol with non default visibility must be satisfied
// in the same DSO.
auto Replace = [&](uint8_t Binding) {
replaceSymbol<SharedSymbol>(S, File, Name, Binding, Sym.st_other,
Sym.getType(), Sym.st_value, Sym.st_size,
Alignment, VerdefIndex);
replaceSymbol<SharedSymbol>(S, *File, Name, Binding, StOther, Type, Value,
Size, Alignment, VerdefIndex);
};
if (WasInserted)
Replace(Sym.getBinding());
Replace(Binding);
else if (S->Visibility == STV_DEFAULT && (S->isUndefined() || S->isLazy()))
Replace(S->Binding);
}
@ -784,16 +783,3 @@ template void SymbolTable::fetchLazy<ELF32LE>(Symbol *);
template void SymbolTable::fetchLazy<ELF32BE>(Symbol *);
template void SymbolTable::fetchLazy<ELF64LE>(Symbol *);
template void SymbolTable::fetchLazy<ELF64BE>(Symbol *);
template void SymbolTable::addShared<ELF32LE>(StringRef, SharedFile &,
const typename ELF32LE::Sym &,
uint32_t Alignment, uint32_t);
template void SymbolTable::addShared<ELF32BE>(StringRef, SharedFile &,
const typename ELF32BE::Sym &,
uint32_t Alignment, uint32_t);
template void SymbolTable::addShared<ELF64LE>(StringRef, SharedFile &,
const typename ELF64LE::Sym &,
uint32_t Alignment, uint32_t);
template void SymbolTable::addShared<ELF64BE>(StringRef, SharedFile &,
const typename ELF64BE::Sym &,
uint32_t Alignment, uint32_t);

View File

@ -48,9 +48,9 @@ public:
uint64_t Value, uint64_t Size, uint8_t Binding,
SectionBase *Section, InputFile *File);
template <class ELFT>
void addShared(StringRef Name, SharedFile &F, const typename ELFT::Sym &Sym,
uint32_t Alignment, uint32_t VerdefIndex);
void addShared(StringRef Name, uint8_t Binding, uint8_t StOther, uint8_t Type,
uint64_t Value, uint64_t Size, uint32_t Alignment,
uint32_t VerdefIndex, InputFile *File);
template <class ELFT>
void addLazyArchive(StringRef Name, ArchiveFile &F,