Simplify getSymbolType.

This is still a really odd function. Most calls are in object format specific
contexts and should probably be replaced with a more direct query, but at least
now this is not too obnoxious to use.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240777 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-06-26 12:18:49 +00:00
parent 5511d97506
commit 50bea40e8e
14 changed files with 54 additions and 103 deletions

View File

@ -136,8 +136,7 @@ protected:
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
uint8_t getSymbolOther(DataRefImpl Symb) const override;
std::error_code getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Res) const override;
SymbolRef::Type getSymbolType(DataRefImpl Symb) const override;
section_iterator getSymbolSection(const Elf_Sym *Symb) const;
std::error_code getSymbolSection(DataRefImpl Symb,
section_iterator &Res) const override;
@ -390,34 +389,25 @@ uint8_t ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const {
}
template <class ELFT>
std::error_code
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Result) const {
SymbolRef::Type ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
const Elf_Sym *ESym = getSymbol(Symb);
switch (ESym->getType()) {
case ELF::STT_NOTYPE:
Result = SymbolRef::ST_Unknown;
break;
return SymbolRef::ST_Unknown;
case ELF::STT_SECTION:
Result = SymbolRef::ST_Debug;
break;
return SymbolRef::ST_Debug;
case ELF::STT_FILE:
Result = SymbolRef::ST_File;
break;
return SymbolRef::ST_File;
case ELF::STT_FUNC:
Result = SymbolRef::ST_Function;
break;
return SymbolRef::ST_Function;
case ELF::STT_OBJECT:
case ELF::STT_COMMON:
case ELF::STT_TLS:
Result = SymbolRef::ST_Data;
break;
return SymbolRef::ST_Data;
default:
Result = SymbolRef::ST_Other;
break;
return SymbolRef::ST_Other;
}
return std::error_code();
}
template <class ELFT>