mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-08 05:16:53 +00:00
Delete getDotSymtabSec.
Another step in avoiding iterating over all sections in the ELFFile constructor. llvm-svn: 244496
This commit is contained in:
parent
65266a8e22
commit
e12302b7c2
@ -78,8 +78,6 @@ public:
|
||||
template <typename T>
|
||||
const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const;
|
||||
|
||||
const Elf_Shdr *getDotSymtabSec() const { return dot_symtab_sec; }
|
||||
|
||||
ErrorOr<StringRef> getStringTable(const Elf_Shdr *Section) const;
|
||||
ErrorOr<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;
|
||||
|
||||
|
@ -193,6 +193,7 @@ protected:
|
||||
ELFFile<ELFT> EF;
|
||||
|
||||
const Elf_Shdr *DotDynSymSec = nullptr; // Dynamic symbol table section.
|
||||
const Elf_Shdr *DotSymtabSec = nullptr; // Symbol table section.
|
||||
|
||||
void moveSymbolNext(DataRefImpl &Symb) const override;
|
||||
ErrorOr<StringRef> getSymbolName(DataRefImpl Symb) const override;
|
||||
@ -477,7 +478,7 @@ uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
|
||||
Result |= SymbolRef::SF_Absolute;
|
||||
|
||||
if (ESym->getType() == ELF::STT_FILE || ESym->getType() == ELF::STT_SECTION ||
|
||||
ESym == EF.symbol_begin(EF.getDotSymtabSec()) ||
|
||||
ESym == EF.symbol_begin(DotSymtabSec) ||
|
||||
ESym == EF.symbol_begin(DotDynSymSec))
|
||||
Result |= SymbolRef::SF_FormatSpecific;
|
||||
|
||||
@ -669,7 +670,7 @@ ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
|
||||
if (IsDyn)
|
||||
SymbolData = toDRI(DotDynSymSec, symbolIdx);
|
||||
else
|
||||
SymbolData = toDRI(EF.getDotSymtabSec(), symbolIdx);
|
||||
SymbolData = toDRI(DotSymtabSec, symbolIdx);
|
||||
return symbol_iterator(SymbolRef(SymbolData, this));
|
||||
}
|
||||
|
||||
@ -746,19 +747,28 @@ ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, std::error_code &EC)
|
||||
DotDynSymSec = &Sec;
|
||||
break;
|
||||
}
|
||||
case ELF::SHT_SYMTAB: {
|
||||
if (DotSymtabSec) {
|
||||
// More than one .dynsym!
|
||||
EC = object_error::parse_failed;
|
||||
return;
|
||||
}
|
||||
DotSymtabSec = &Sec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin_impl() const {
|
||||
DataRefImpl Sym = toDRI(EF.getDotSymtabSec(), 0);
|
||||
DataRefImpl Sym = toDRI(DotSymtabSec, 0);
|
||||
return basic_symbol_iterator(SymbolRef(Sym, this));
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end_impl() const {
|
||||
const Elf_Shdr *SymTab = EF.getDotSymtabSec();
|
||||
const Elf_Shdr *SymTab = DotSymtabSec;
|
||||
if (!SymTab)
|
||||
return symbol_begin_impl();
|
||||
DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
|
||||
|
@ -305,13 +305,14 @@ void OpcodeDecoder::Decode(const uint8_t *Opcodes, off_t Offset, size_t Length)
|
||||
|
||||
template <typename ET>
|
||||
class PrinterContext {
|
||||
StreamWriter &SW;
|
||||
const object::ELFFile<ET> *ELF;
|
||||
|
||||
typedef typename object::ELFFile<ET>::Elf_Sym Elf_Sym;
|
||||
typedef typename object::ELFFile<ET>::Elf_Shdr Elf_Shdr;
|
||||
typedef typename object::ELFFile<ET>::Elf_Rel Elf_Rel;
|
||||
|
||||
StreamWriter &SW;
|
||||
const object::ELFFile<ET> *ELF;
|
||||
const Elf_Shdr *Symtab;
|
||||
|
||||
static const size_t IndexTableEntrySize;
|
||||
|
||||
static uint64_t PREL31(uint32_t Address, uint32_t Place) {
|
||||
@ -331,8 +332,9 @@ class PrinterContext {
|
||||
void PrintOpcodes(const uint8_t *Entry, size_t Length, off_t Offset) const;
|
||||
|
||||
public:
|
||||
PrinterContext(StreamWriter &Writer, const object::ELFFile<ET> *File)
|
||||
: SW(Writer), ELF(File) {}
|
||||
PrinterContext(StreamWriter &SW, const object::ELFFile<ET> *ELF,
|
||||
const Elf_Shdr *Symtab)
|
||||
: SW(SW), ELF(ELF), Symtab(Symtab) {}
|
||||
|
||||
void PrintUnwindInformation() const;
|
||||
};
|
||||
@ -344,12 +346,11 @@ template <typename ET>
|
||||
ErrorOr<StringRef>
|
||||
PrinterContext<ET>::FunctionAtAddress(unsigned Section,
|
||||
uint64_t Address) const {
|
||||
const Elf_Shdr *Symtab = ELF->getDotSymtabSec();
|
||||
ErrorOr<StringRef> StrTableOrErr = ELF->getStringTableForSymtab(*Symtab);
|
||||
error(StrTableOrErr.getError());
|
||||
StringRef StrTable = *StrTableOrErr;
|
||||
|
||||
for (const Elf_Sym &Sym : ELF->symbols(ELF->getDotSymtabSec()))
|
||||
for (const Elf_Sym &Sym : ELF->symbols(Symtab))
|
||||
if (Sym.st_shndx == Section && Sym.st_value == Address &&
|
||||
Sym.getType() == ELF::STT_FUNC)
|
||||
return Sym.getName(StrTable);
|
||||
|
@ -134,6 +134,7 @@ private:
|
||||
StringRef SOName;
|
||||
const Elf_Hash *HashTable = nullptr;
|
||||
const Elf_Shdr *DotDynSymSec = nullptr;
|
||||
const Elf_Shdr *DotSymtabSec = nullptr;
|
||||
|
||||
const Elf_Shdr *dot_gnu_version_sec = nullptr; // .gnu.version
|
||||
const Elf_Shdr *dot_gnu_version_r_sec = nullptr; // .gnu.version_r
|
||||
@ -383,7 +384,7 @@ getSectionNameIndex(const ELFO &Obj, const typename ELFO::Elf_Sym *Symbol,
|
||||
SectionName = "Reserved";
|
||||
else {
|
||||
if (SectionIndex == SHN_XINDEX)
|
||||
SectionIndex = Obj.getExtendedSymbolTableIndex(&*Symbol);
|
||||
SectionIndex = Obj.getExtendedSymbolTableIndex(Symbol);
|
||||
ErrorOr<const typename ELFO::Elf_Shdr *> Sec = Obj.getSection(SectionIndex);
|
||||
error(Sec.getError());
|
||||
SectionName = errorOrDefault(Obj.getSectionName(*Sec));
|
||||
@ -891,6 +892,11 @@ ELFDumper<ELFT>::ELFDumper(const ELFFile<ELFT> *Obj, StreamWriter &Writer)
|
||||
reportError("Multilpe SHT_DYNSYM");
|
||||
DotDynSymSec = &Sec;
|
||||
break;
|
||||
case ELF::SHT_SYMTAB:
|
||||
if (DotSymtabSec != nullptr)
|
||||
reportError("Multilpe SHT_SYMTAB");
|
||||
DotSymtabSec = &Sec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -997,7 +1003,7 @@ void ELFDumper<ELFT>::printSections() {
|
||||
|
||||
if (opts::SectionSymbols) {
|
||||
ListScope D(W, "Symbols");
|
||||
const Elf_Shdr *Symtab = Obj->getDotSymtabSec();
|
||||
const Elf_Shdr *Symtab = DotSymtabSec;
|
||||
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
|
||||
error(StrTableOrErr.getError());
|
||||
StringRef StrTable = *StrTableOrErr;
|
||||
@ -1129,7 +1135,7 @@ template<class ELFT>
|
||||
void ELFDumper<ELFT>::printSymbols() {
|
||||
ListScope Group(W, "Symbols");
|
||||
|
||||
const Elf_Shdr *Symtab = Obj->getDotSymtabSec();
|
||||
const Elf_Shdr *Symtab = DotSymtabSec;
|
||||
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
|
||||
error(StrTableOrErr.getError());
|
||||
StringRef StrTable = *StrTableOrErr;
|
||||
@ -1412,7 +1418,8 @@ namespace {
|
||||
template <> void ELFDumper<ELFType<support::little, false>>::printUnwindInfo() {
|
||||
const unsigned Machine = Obj->getHeader()->e_machine;
|
||||
if (Machine == EM_ARM) {
|
||||
ARM::EHABI::PrinterContext<ELFType<support::little, false>> Ctx(W, Obj);
|
||||
ARM::EHABI::PrinterContext<ELFType<support::little, false>> Ctx(
|
||||
W, Obj, DotSymtabSec);
|
||||
return Ctx.PrintUnwindInformation();
|
||||
}
|
||||
W.startLine() << "UnwindInfo not implemented.\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user