mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 18:24:34 +00:00
Adding convenience function to ELF Header
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167852 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -609,6 +609,7 @@ public:
|
|||||||
const Elf_Dyn *getDyn(DataRefImpl DynData) const;
|
const Elf_Dyn *getDyn(DataRefImpl DynData) const;
|
||||||
error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
|
error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
|
||||||
bool &IsDefault) const;
|
bool &IsDefault) const;
|
||||||
|
uint64_t getSymbolIndex(const Elf_Sym *sym) const;
|
||||||
protected:
|
protected:
|
||||||
virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const;
|
virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const;
|
||||||
virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const;
|
virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const;
|
||||||
@@ -2094,6 +2095,21 @@ ELFObjectFile<target_endianness, is64Bits>::ELFObjectFile(MemoryBuffer *Object
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the symbol table index in the symtab section given a symbol
|
||||||
|
template<support::endianness target_endianness, bool is64Bits>
|
||||||
|
uint64_t ELFObjectFile<target_endianness, is64Bits>
|
||||||
|
::getSymbolIndex(const Elf_Sym *Sym) const {
|
||||||
|
assert(SymbolTableSections.size() == 1 && "Only one symbol table supported!");
|
||||||
|
const Elf_Shdr *SymTab = *SymbolTableSections.begin();
|
||||||
|
uintptr_t SymLoc = uintptr_t(Sym);
|
||||||
|
uintptr_t SymTabLoc = uintptr_t(base() + SymTab->sh_offset);
|
||||||
|
assert(SymLoc > SymTabLoc && "Symbol not in symbol table!");
|
||||||
|
uint64_t SymOffset = SymLoc - SymTabLoc;
|
||||||
|
assert(SymOffset % SymTab->sh_entsize == 0 &&
|
||||||
|
"Symbol not multiple of symbol size!");
|
||||||
|
return SymOffset / SymTab->sh_entsize;
|
||||||
|
}
|
||||||
|
|
||||||
template<support::endianness target_endianness, bool is64Bits>
|
template<support::endianness target_endianness, bool is64Bits>
|
||||||
symbol_iterator ELFObjectFile<target_endianness, is64Bits>
|
symbol_iterator ELFObjectFile<target_endianness, is64Bits>
|
||||||
::begin_symbols() const {
|
::begin_symbols() const {
|
||||||
|
Reference in New Issue
Block a user