LLVM
15.0.0git
|
#include "llvm/Object/ELF.h"
Public Types | |
using | WarningHandler = llvm::function_ref< Error(const Twine &Msg)> |
Public Member Functions | |
const uint8_t * | base () const |
const uint8_t * | end () const |
size_t | getBufSize () const |
const Elf_Ehdr & | getHeader () const |
template<typename T > | |
Expected< const T * > | getEntry (uint32_t Section, uint32_t Entry) const |
template<typename T > | |
Expected< const T * > | getEntry (const Elf_Shdr &Section, uint32_t Entry) const |
Expected< std::vector< VerDef > > | getVersionDefinitions (const Elf_Shdr &Sec) const |
Expected< std::vector< VerNeed > > | getVersionDependencies (const Elf_Shdr &Sec, WarningHandler WarnHandler=&defaultWarningHandler) const |
Expected< StringRef > | getSymbolVersionByIndex (uint32_t SymbolVersionIndex, bool &IsDefault, SmallVector< Optional< VersionEntry >, 0 > &VersionMap, Optional< bool > IsSymHidden) const |
Expected< StringRef > | getStringTable (const Elf_Shdr &Section, WarningHandler WarnHandler=&defaultWarningHandler) const |
Expected< StringRef > | getStringTableForSymtab (const Elf_Shdr &Section) const |
Expected< StringRef > | getStringTableForSymtab (const Elf_Shdr &Section, Elf_Shdr_Range Sections) const |
Expected< StringRef > | getLinkAsStrtab (const typename ELFT::Shdr &Sec) const |
Expected< ArrayRef< Elf_Word > > | getSHNDXTable (const Elf_Shdr &Section) const |
Expected< ArrayRef< Elf_Word > > | getSHNDXTable (const Elf_Shdr &Section, Elf_Shdr_Range Sections) const |
Expected< uint64_t > | getDynSymtabSize () const |
This function determines the number of dynamic symbols. More... | |
StringRef | getRelocationTypeName (uint32_t Type) const |
void | getRelocationTypeName (uint32_t Type, SmallVectorImpl< char > &Result) const |
uint32_t | getRelativeRelocationType () const |
std::string | getDynamicTagAsString (unsigned Arch, uint64_t Type) const |
std::string | getDynamicTagAsString (uint64_t Type) const |
Expected< const Elf_Sym * > | getRelocationSymbol (const Elf_Rel &Rel, const Elf_Shdr *SymTab) const |
Get the symbol for a given relocation. More... | |
Expected< SmallVector< Optional< VersionEntry >, 0 > > | loadVersionMap (const Elf_Shdr *VerNeedSec, const Elf_Shdr *VerDefSec) const |
bool | isLE () const |
bool | isMipsELF64 () const |
bool | isMips64EL () const |
Expected< Elf_Shdr_Range > | sections () const |
Expected< Elf_Dyn_Range > | dynamicEntries () const |
Expected< const uint8_t * > | toMappedAddr (uint64_t VAddr, WarningHandler WarnHandler=&defaultWarningHandler) const |
Expected< Elf_Sym_Range > | symbols (const Elf_Shdr *Sec) const |
Expected< Elf_Rela_Range > | relas (const Elf_Shdr &Sec) const |
Expected< Elf_Rel_Range > | rels (const Elf_Shdr &Sec) const |
Expected< Elf_Relr_Range > | relrs (const Elf_Shdr &Sec) const |
std::vector< Elf_Rel > | decode_relrs (Elf_Relr_Range relrs) const |
Expected< std::vector< Elf_Rela > > | android_relas (const Elf_Shdr &Sec) const |
Expected< Elf_Phdr_Range > | program_headers () const |
Iterate over program header table. More... | |
Elf_Note_Iterator | notes_begin (const Elf_Phdr &Phdr, Error &Err) const |
Get an iterator over notes in a program header. More... | |
Elf_Note_Iterator | notes_begin (const Elf_Shdr &Shdr, Error &Err) const |
Get an iterator over notes in a section. More... | |
Elf_Note_Iterator | notes_end () const |
Get the end iterator for notes. More... | |
iterator_range< Elf_Note_Iterator > | notes (const Elf_Phdr &Phdr, Error &Err) const |
Get an iterator range over notes of a program header. More... | |
iterator_range< Elf_Note_Iterator > | notes (const Elf_Shdr &Shdr, Error &Err) const |
Get an iterator range over notes of a section. More... | |
Expected< StringRef > | getSectionStringTable (Elf_Shdr_Range Sections, WarningHandler WarnHandler=&defaultWarningHandler) const |
Expected< uint32_t > | getSectionIndex (const Elf_Sym &Sym, Elf_Sym_Range Syms, DataRegion< Elf_Word > ShndxTable) const |
Expected< const Elf_Shdr * > | getSection (const Elf_Sym &Sym, const Elf_Shdr *SymTab, DataRegion< Elf_Word > ShndxTable) const |
Expected< const Elf_Shdr * > | getSection (const Elf_Sym &Sym, Elf_Sym_Range Symtab, DataRegion< Elf_Word > ShndxTable) const |
Expected< const Elf_Shdr * > | getSection (uint32_t Index) const |
Expected< const Elf_Sym * > | getSymbol (const Elf_Shdr *Sec, uint32_t Index) const |
Expected< StringRef > | getSectionName (const Elf_Shdr &Section, WarningHandler WarnHandler=&defaultWarningHandler) const |
Expected< StringRef > | getSectionName (const Elf_Shdr &Section, StringRef DotShstrtab) const |
template<typename T > | |
Expected< ArrayRef< T > > | getSectionContentsAsArray (const Elf_Shdr &Sec) const |
Expected< ArrayRef< uint8_t > > | getSectionContents (const Elf_Shdr &Sec) const |
Expected< ArrayRef< uint8_t > > | getSegmentContents (const Elf_Phdr &Phdr) const |
Expected< std::vector< BBAddrMap > > | decodeBBAddrMap (const Elf_Shdr &Sec) const |
Static Public Member Functions | |
static Expected< ELFFile > | create (StringRef Object) |
using llvm::object::ELFFile< ELFT >::WarningHandler = llvm::function_ref<Error(const Twine &Msg)> |
Expected< std::vector< typename ELFT::Rela > > ELFFile::android_relas | ( | const Elf_Shdr & | Sec | ) | const |
Definition at line 375 of file ELF.cpp.
References Content, llvm::object::createError(), llvm::Data, I, move, llvm::ELF::RELOCATION_GROUP_HAS_ADDEND_FLAG, llvm::ELF::RELOCATION_GROUPED_BY_ADDEND_FLAG, llvm::ELF::RELOCATION_GROUPED_BY_INFO_FLAG, llvm::ELF::RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG, llvm::DataExtractor::Cursor::takeError(), and llvm::Expected< T >::takeError().
|
inline |
Definition at line 177 of file ELF.h.
References llvm::StringRef::bytes_begin().
Referenced by llvm::object::ELFFile< ELFT >::end(), llvm::object::ELFFile< ELFT >::getHeader(), and llvm::object::ELFFile< ELFT >::program_headers().
|
static |
Definition at line 752 of file ELF.h.
References llvm::object::createError(), and llvm::Object.
Referenced by llvm::objcopy::elf::ELFBuilder< ELFT >::build(), llvm::object::ELFObjectFile< ELFT >::create(), and llvm::jitlink::readTargetMachineArch().
std::vector< typename ELFT::Rel > ELFFile::decode_relrs | ( | Elf_Relr_Range | relrs | ) | const |
Definition at line 311 of file ELF.cpp.
References Addr, llvm::sampleprof::Base, and uint.
Expected< std::vector< BBAddrMap > > ELFFile::decodeBBAddrMap | ( | const Elf_Shdr & | Sec | ) | const |
Definition at line 633 of file ELF.cpp.
References Content, llvm::object::createError(), llvm::Data, llvm::joinErrors(), move, llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::Twine::utohexstr().
Expected< typename ELFT::DynRange > ELFFile::dynamicEntries | ( | ) | const |
Definition at line 532 of file ELF.cpp.
References llvm::ArrayRef< T >::back(), base, llvm::object::createError(), llvm::ArrayRef< T >::data(), llvm::ArrayRef< T >::empty(), llvm::makeArrayRef(), llvm::ELF::PT_DYNAMIC, llvm::ELF::SHT_DYNAMIC, and llvm::Expected< T >::takeError().
|
inline |
Definition at line 178 of file ELF.h.
References llvm::object::ELFFile< ELFT >::base(), and llvm::object::ELFFile< ELFT >::getBufSize().
|
inline |
Definition at line 180 of file ELF.h.
References llvm::StringRef::size().
Referenced by llvm::object::ELFFile< ELFT >::end(), and llvm::object::ELFFile< ELFT >::program_headers().
std::string ELFFile::getDynamicTagAsString | ( | uint64_t | Type | ) | const |
std::string ELFFile::getDynamicTagAsString | ( | unsigned | Arch, |
uint64_t | Type | ||
) | const |
Definition at line 443 of file ELF.cpp.
References llvm::ELF::EM_AARCH64, llvm::ELF::EM_HEXAGON, llvm::ELF::EM_MIPS, llvm::ELF::EM_PPC, llvm::ELF::EM_PPC64, and llvm::ELF::EM_RISCV.
Expected< uint64_t > llvm::object::ELFFile< ELFT >::getDynSymtabSize |
This function determines the number of dynamic symbols.
It reads section headers first. If section headers are not available, the number of symbols will be inferred by parsing dynamic hash tables.
Definition at line 689 of file ELF.h.
References llvm::createStringError(), llvm::object::parse_failed, llvm::ELF::SHT_DYNSYM, and llvm::Expected< T >::takeError().
|
inline |
Definition at line 188 of file ELF.h.
References llvm::object::ELFFile< ELFT >::base().
Referenced by llvm::object::describe(), llvm::object::ELFFile< ELFT >::isLE(), llvm::object::ELFFile< ELFT >::isMipsELF64(), llvm::jitlink::ELFLinkGraphBuilder< object::ELF64LE >::isRelocatable(), and llvm::object::ELFFile< ELFT >::program_headers().
Expected< StringRef > llvm::object::ELFFile< ELFT >::getLinkAsStrtab | ( | const typename ELFT::Shdr & | Sec | ) | const |
Definition at line 1139 of file ELF.h.
References llvm::object::createError(), llvm::object::describe(), llvm::object::getSection(), llvm::Expected< T >::takeError(), and llvm::toString().
uint32_t llvm::object::ELFFile< ELFT >::getRelativeRelocationType |
Definition at line 580 of file ELF.h.
References llvm::object::getELFRelativeRelocationType().
Expected< const typename ELFT::Sym * > llvm::object::ELFFile< ELFT >::getRelocationSymbol | ( | const Elf_Rel & | Rel, |
const Elf_Shdr * | SymTab | ||
) | const |
Get the symbol for a given relocation.
Definition at line 623 of file ELF.h.
References isMips64EL().
StringRef llvm::object::ELFFile< ELFT >::getRelocationTypeName | ( | uint32_t | Type | ) | const |
Definition at line 544 of file ELF.h.
References llvm::object::getELFRelocationTypeName().
void llvm::object::ELFFile< ELFT >::getRelocationTypeName | ( | uint32_t | Type, |
SmallVectorImpl< char > & | Result | ||
) | const |
Expected< const typename ELFT::Shdr * > llvm::object::ELFFile< ELFT >::getSection | ( | const Elf_Sym & | Sym, |
const Elf_Shdr * | SymTab, | ||
DataRegion< Elf_Word > | ShndxTable | ||
) | const |
Definition at line 444 of file ELF.h.
References llvm::object::getSection(), and symbols.
Expected< const typename ELFT::Shdr * > llvm::object::ELFFile< ELFT >::getSection | ( | const Elf_Sym & | Sym, |
Elf_Sym_Range | Symtab, | ||
DataRegion< Elf_Word > | ShndxTable | ||
) | const |
Definition at line 454 of file ELF.h.
References llvm::object::getSection().
Expected< const typename ELFT::Shdr * > llvm::object::ELFFile< ELFT >::getSection | ( | uint32_t | Index | ) | const |
Expected< ArrayRef< uint8_t > > llvm::object::ELFFile< ELFT >::getSectionContents | ( | const Elf_Shdr & | Sec | ) | const |
Expected< ArrayRef< T > > llvm::object::ELFFile< ELFT >::getSectionContentsAsArray | ( | const Elf_Shdr & | Sec | ) | const |
Definition at line 483 of file ELF.h.
References base, llvm::object::createError(), llvm::object::getSecIndexForError(), llvm::makeArrayRef(), llvm::max(), T, and llvm::Twine::utohexstr().
Expected< uint32_t > llvm::object::ELFFile< ELFT >::getSectionIndex | ( | const Elf_Sym & | Sym, |
Elf_Sym_Range | Syms, | ||
DataRegion< Elf_Word > | ShndxTable | ||
) | const |
Definition at line 427 of file ELF.h.
References llvm::ELF::SHN_LORESERVE, llvm::ELF::SHN_UNDEF, llvm::ELF::SHN_XINDEX, and llvm::Expected< T >::takeError().
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSectionName | ( | const Elf_Shdr & | Section, |
StringRef | DotShstrtab | ||
) | const |
Definition at line 1168 of file ELF.h.
References llvm::object::createError(), llvm::StringRef::data(), llvm::object::getSecIndexForError(), llvm::StringRef::size(), and llvm::Twine::utohexstr().
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSectionName | ( | const Elf_Shdr & | Section, |
WarningHandler | WarnHandler = &defaultWarningHandler |
||
) | const |
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSectionStringTable | ( | Elf_Shdr_Range | Sections, |
WarningHandler | WarnHandler = &defaultWarningHandler |
||
) | const |
Definition at line 633 of file ELF.h.
References llvm::object::createError(), and llvm::ELF::SHN_XINDEX.
Expected< ArrayRef< uint8_t > > llvm::object::ELFFile< ELFT >::getSegmentContents | ( | const Elf_Phdr & | Phdr | ) | const |
Definition at line 519 of file ELF.h.
References base, llvm::object::createError(), llvm::object::getPhdrIndexForError(), llvm::makeArrayRef(), llvm::max(), and llvm::Twine::utohexstr().
Expected< ArrayRef< typename ELFT::Word > > llvm::object::ELFFile< ELFT >::getSHNDXTable | ( | const Elf_Shdr & | Section | ) | const |
Expected< ArrayRef< typename ELFT::Word > > llvm::object::ELFFile< ELFT >::getSHNDXTable | ( | const Elf_Shdr & | Section, |
Elf_Shdr_Range | Sections | ||
) | const |
Definition at line 1086 of file ELF.h.
References assert(), llvm::object::createError(), llvm::object::getELFSectionTypeName(), llvm::ELF::SHT_DYNSYM, llvm::ELF::SHT_SYMTAB, llvm::ELF::SHT_SYMTAB_SHNDX, and llvm::ArrayRef< T >::size().
Expected< StringRef > llvm::object::ELFFile< ELFT >::getStringTable | ( | const Elf_Shdr & | Section, |
WarningHandler | WarnHandler = &defaultWarningHandler |
||
) | const |
Definition at line 1051 of file ELF.h.
References llvm::object::createError(), llvm::Data, E, llvm::object::getELFSectionTypeName(), llvm::object::getSecIndexForError(), move, and llvm::ELF::SHT_STRTAB.
Expected< StringRef > llvm::object::ELFFile< ELFT >::getStringTableForSymtab | ( | const Elf_Shdr & | Section | ) | const |
Expected< StringRef > llvm::object::ELFFile< ELFT >::getStringTableForSymtab | ( | const Elf_Shdr & | Section, |
Elf_Shdr_Range | Sections | ||
) | const |
Definition at line 1124 of file ELF.h.
References llvm::object::createError(), llvm::ELF::SHT_DYNSYM, llvm::ELF::SHT_SYMTAB, and llvm::Expected< T >::takeError().
Expected< const typename ELFT::Sym * > llvm::object::ELFFile< ELFT >::getSymbol | ( | const Elf_Shdr * | Sec, |
uint32_t | Index | ||
) | const |
Definition at line 467 of file ELF.h.
References llvm::object::createError(), llvm::object::getSecIndexForError(), and symbols.
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSymbolVersionByIndex | ( | uint32_t | SymbolVersionIndex, |
bool & | IsDefault, | ||
SmallVector< Optional< VersionEntry >, 0 > & | VersionMap, | ||
Optional< bool > | IsSymHidden | ||
) | const |
Definition at line 838 of file ELF.h.
References llvm::object::createError(), llvm::ELF::VER_NDX_GLOBAL, llvm::ELF::VER_NDX_LOCAL, and llvm::ELF::VERSYM_VERSION.
Expected< std::vector< VerDef > > llvm::object::ELFFile< ELFT >::getVersionDefinitions | ( | const Elf_Shdr & | Sec | ) | const |
Definition at line 867 of file ELF.h.
References llvm::object::createError(), llvm::object::describe(), llvm::Expected< T >::takeError(), and llvm::toString().
Expected< std::vector< VerNeed > > llvm::object::ELFFile< ELFT >::getVersionDependencies | ( | const Elf_Shdr & | Sec, |
WarningHandler | WarnHandler = &defaultWarningHandler |
||
) | const |
Definition at line 954 of file ELF.h.
References llvm::object::createError(), llvm::object::describe(), E, move, llvm::Expected< T >::takeError(), and llvm::toString().
|
inline |
Definition at line 238 of file ELF.h.
References llvm::ELF::ELFDATA2LSB, and llvm::object::ELFFile< ELFT >::getHeader().
Referenced by llvm::object::ELFFile< ELFT >::isMips64EL().
|
inline |
Definition at line 247 of file ELF.h.
References llvm::object::ELFFile< ELFT >::isLE(), and llvm::object::ELFFile< ELFT >::isMipsELF64().
|
inline |
Definition at line 242 of file ELF.h.
References llvm::ELF::ELFCLASS64, llvm::ELF::EM_MIPS, and llvm::object::ELFFile< ELFT >::getHeader().
Referenced by llvm::object::ELFFile< ELFT >::isMips64EL().
Expected< SmallVector< Optional< VersionEntry >, 0 > > llvm::object::ELFFile< ELFT >::loadVersionMap | ( | const Elf_Shdr * | VerNeedSec, |
const Elf_Shdr * | VerDefSec | ||
) | const |
Definition at line 586 of file ELF.h.
References llvm::tgtok::Def, N, llvm::object::VernAux::Name, llvm::object::VernAux::Other, llvm::SmallVectorImpl< T >::resize(), llvm::Expected< T >::takeError(), Version, and llvm::ELF::VERSYM_VERSION.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Iterate over program header table.
Definition at line 280 of file ELF.h.
References llvm::object::ELFFile< ELFT >::base(), llvm::object::createError(), llvm::object::ELFFile< ELFT >::getBufSize(), llvm::object::ELFFile< ELFT >::getHeader(), llvm::makeArrayRef(), and llvm::Twine::utohexstr().
Referenced by llvm::object::getPhdrIndexForError().
|
inline |
|
inline |
|
inline |
Expected< typename ELFT::ShdrRange > llvm::object::ELFFile< ELFT >::sections |
Definition at line 761 of file ELF.h.
References base, llvm::object::createError(), First, llvm::makeArrayRef(), UINT64_MAX, and llvm::Twine::utohexstr().
Referenced by llvm::object::describe(), and llvm::object::getSecIndexForError().
|
inline |
Expected< const uint8_t * > ELFFile::toMappedAddr | ( | uint64_t | VAddr, |
WarningHandler | WarnHandler = &defaultWarningHandler |
||
) | const |
Definition at line 581 of file ELF.cpp.
References B, base, llvm::object::createError(), E, I, llvm::is_sorted(), move, llvm::ELF::PT_LOAD, llvm::stable_sort(), llvm::upper_bound(), and llvm::Twine::utohexstr().