LLVM: llvm::object::ELFFile< ELFT > Class Template Reference (original) (raw)

#include "[llvm/Object/ELF.h](Object%5F2ELF%5F8h%5Fsource.html)"

Public Member Functions
ELFFile (const ELFFile &)=default
ELFFile & operator= (const ELFFile &)=default
ELFFile (ELFFile &&)=default
const uint8_t * base () const
const uint8_t * end () const
size_t getBufSize () const
Expected< uint32_t > getPhNum () const
Expected< uint64_t > getShNum () const
Expected< uint32_t > getShStrNdx () 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< std::optional< VersionEntry >, 0 > &VersionMap, std::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.
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.
Expected< SmallVector< std::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< uint64_t > getCrelHeader (ArrayRef< uint8_t > Content) const
Expected< RelsOrRelas > decodeCrel (ArrayRef< uint8_t > Content) const
Expected< RelsOrRelas > crels (const Elf_Shdr &Sec) 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.
Elf_Note_Iterator notes_begin (const Elf_Phdr &Phdr, Error &Err) const
Get an iterator over notes in a program header.
Elf_Note_Iterator notes_begin (const Elf_Shdr &Shdr, Error &Err) const
Get an iterator over notes in a section.
Elf_Note_Iterator notes_end () const
Get the end iterator for notes.
iterator_range< Elf_Note_Iterator > notes (const Elf_Phdr &Phdr, Error &Err) const
Get an iterator range over notes of a program header.
iterator_range< Elf_Note_Iterator > notes (const Elf_Shdr &Shdr, Error &Err) const
Get an iterator range over notes of a section.
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 Elf_Shdr *RelaSec=nullptr, std::vector< PGOAnalysisMap > *PGOAnalyses=nullptr) const
Returns a vector of BBAddrMap structs corresponding to each function within the text section that the SHT_LLVM_BB_ADDR_MAP section Sec is associated with.
Expected< MapVector< const Elf_Shdr *, const Elf_Shdr * > > getSectionAndRelocations (std::function< Expected< bool >(const Elf_Shdr &)> IsMatch) const
Returns a map from every section matching IsMatch to its relocation section, or nullptr if it has no relocation section.
void createFakeSections ()
Used by llvm-objdump -d (which needs sections for disassembly) to disassemble objects without a section header table (e.g.

template
class llvm::object::ELFFile< ELFT >

Definition at line 257 of file ELF.h.

RelsOrRelas

template

using llvm::object::ELFFile< ELFT >::RelsOrRelas = std::pair<std::vector<Elf_Rel>, std::vector<Elf_Rela>>

Definition at line 415 of file ELF.h.

WarningHandler

ELFFile() [1/2]

ELFFile() [2/2]

android_relas()

template

Expected< std::vector< typename ELFT::Rela > > ELFFile::android_relas ( const Elf_Shdr & Sec ) const

Definition at line 468 of file ELF.cpp.

References llvm::object::createError(), llvm::Data, getSectionContents(), I, isLE(), llvm::Offset, 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::ArrayRef< T >::size(), llvm::DataExtractor::Cursor::takeError(), and llvm::Expected< T >::takeError().

base()

create()

createFakeSections()

crels()

decode_relrs()

template

std::vector< typename ELFT::Rel > ELFFile::decode_relrs ( Elf_Relr_Range relrs ) const

decodeBBAddrMap()

Returns a vector of BBAddrMap structs corresponding to each function within the text section that the SHT_LLVM_BB_ADDR_MAP section Sec is associated with.

If the current ELFFile is relocatable, a corresponding RelaSec must be passed in as an argument. Optional out variable to collect all PGO Analyses. New elements are only added if no error occurs. If not provided, the PGO Analyses are decoded then ignored.

Definition at line 1011 of file ELF.cpp.

References decodeBBAddrMapImpl().

Referenced by readBBAddrMapImpl().

decodeCrel()

dynamicEntries()

template

Expected< typename ELFT::DynRange > ELFFile::dynamicEntries ( ) const

Definition at line 625 of file ELF.cpp.

References llvm::ArrayRef(), llvm::ArrayRef< T >::back(), base(), llvm::object::createError(), llvm::ArrayRef< T >::data(), llvm::ArrayRef< T >::empty(), end(), getSectionContentsAsArray(), program_headers(), llvm::ELF::PT_DYNAMIC, sections, llvm::ELF::SHT_DYNAMIC, and llvm::Expected< T >::takeError().

Referenced by llvm::ifs::buildStub(), llvm::orc::getDynamicStrTab(), getDynSymtabSize(), and llvm::orc::parseELF().

end()

getBufSize()

getCrelHeader()

getDynamicTagAsString() [1/2]

template

std::string ELFFile::getDynamicTagAsString ( uint64_t Type ) const

getDynamicTagAsString() [2/2]

template

std::string ELFFile::getDynamicTagAsString ( unsigned Arch,
uint64_t Type ) const

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 873 of file ELF.h.

References llvm::StringRef::bytes_end(), llvm::createStringError(), dynamicEntries(), llvm::Expected< T >::get(), llvm::object::getDynSymtabSizeFromGnuHash(), llvm::object::parse_failed, sections, llvm::ELF::SHT_DYNSYM, llvm::Expected< T >::takeError(), and toMappedAddr().

Referenced by llvm::ifs::buildStub().

getEntry() [1/2]

template

template<typename T>

getEntry() [2/2]

template

template<typename T>

getHeader()

Definition at line 325 of file ELF.h.

Referenced by llvm::ifs::buildStub(), decodeBBAddrMapImpl(), llvm::offloading::amdgpu::getAMDGPUMetaDataFromImage(), getDynamicTagAsString(), getRelativeRelocationType(), getRelocationTypeName(), getSHNDXTable(), getStringTable(), llvm::orc::isELFSharedLibrary(), llvm::object::ELFFile< ELF32LE >::isLE(), llvm::object::ELFFile< ELF32LE >::isMipsELF64(), llvm::object::ELFFile< ELF32LE >::program_headers(), readBBAddrMapImpl(), and sections().

getLinkAsStrtab()

getPhNum()

getRelativeRelocationType()

getRelocationSymbol()

getRelocationTypeName() [1/2]

getRelocationTypeName() [2/2]

getSection() [1/3]

getSection() [2/3]

getSection() [3/3]

getSectionAndRelocations()

Returns a map from every section matching IsMatch to its relocation section, or nullptr if it has no relocation section.

This function returns an error if any of the IsMatch calls fail or if it fails to retrieve the content section of any relocation section.

Definition at line 1024 of file ELF.cpp.

References llvm::cantFail(), llvm::object::createError(), llvm::object::describe(), llvm::object::getSection(), llvm::joinErrors(), sections, llvm::ELF::SHT_CREL, llvm::ELF::SHT_REL, llvm::ELF::SHT_RELA, llvm::Error::success(), llvm::Expected< T >::takeError(), llvm::toString(), and llvm::MapVector< KeyT, ValueT, MapType, VectorType >::try_emplace().

Referenced by readBBAddrMapImpl().

getSectionContents()

getSectionContentsAsArray()

Definition at line 668 of file ELF.h.

References llvm::ArrayRef(), base(), llvm::object::createError(), llvm::object::getSecIndexForError(), llvm::Offset, Size, T, and llvm::Twine::utohexstr().

Referenced by dynamicEntries(), getEntry(), getSectionContents(), getSHNDXTable(), getStringTable(), llvm::object::ELFFile< ELF32LE >::relas(), llvm::object::ELFFile< ELF32LE >::relrs(), llvm::object::ELFFile< ELF32LE >::rels(), and llvm::object::ELFFile< ELF32LE >::symbols().

getSectionIndex()

getSectionName() [1/2]

getSectionName() [2/2]

getSectionStringTable()

getSegmentContents()

getSHNDXTable() [1/2]

getSHNDXTable() [2/2]

getShNum()

getShStrNdx()

getStringTable()

getStringTableForSymtab() [1/2]

getStringTableForSymtab() [2/2]

getSymbol()

getSymbolVersionByIndex()

getVersionDefinitions()

Definition at line 1113 of file ELF.h.

References llvm::object::VerDef::AuxV, llvm::object::VerDef::Cnt, llvm::object::createError(), D(), llvm::object::describe(), llvm::object::VerDef::Flags, getLinkAsStrtab(), getSectionContents(), llvm::object::VerDef::Hash, I, llvm::object::VerdAux::Name, llvm::object::VerDef::Name, llvm::object::VerDef::Ndx, llvm::object::VerdAux::Offset, llvm::object::VerDef::Offset, llvm::Expected< T >::takeError(), llvm::toString(), llvm::Twine::utohexstr(), llvm::object::VerDef::Version, and llvm::Version.

Referenced by loadVersionMap().

getVersionDependencies()

Definition at line 1200 of file ELF.h.

References llvm::object::VerNeed::AuxV, llvm::object::VerNeed::Cnt, llvm::object::createError(), llvm::StringRef::data(), llvm::object::describe(), llvm::StringRef::drop_front(), E(), llvm::object::VerNeed::File, llvm::object::VernAux::Flags, getLinkAsStrtab(), getSectionContents(), llvm::object::VernAux::Hash, I, llvm::object::VernAux::Name, llvm::object::VernAux::Offset, llvm::object::VerNeed::Offset, llvm::object::VernAux::Other, llvm::StringRef::size(), llvm::Expected< T >::takeError(), llvm::toString(), llvm::Twine::utohexstr(), llvm::object::VerNeed::Version, and llvm::Version.

Referenced by loadVersionMap().

isLE()

isMips64EL()

isMipsELF64()

loadVersionMap()

Definition at line 771 of file ELF.h.

References getVersionDefinitions(), getVersionDependencies(), N, llvm::object::VernAux::Name, llvm::object::VernAux::Other, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::resize(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::Expected< T >::takeError(), llvm::Version, and llvm::ELF::VERSYM_VERSION.

Referenced by readDynsymVersionsImpl().

notes() [1/2]

Get an iterator range over notes of a program header.

The program header must be of type PT_NOTE.

Parameters

Phdr the program header to iterate over.
Err [out] an error to support fallible iteration, which should be checked after iteration ends.

Definition at line 514 of file ELF.h.

Referenced by llvm::offloading::amdgpu::getAMDGPUMetaDataFromImage().

notes() [2/2]

Get an iterator range over notes of a section.

The section must be of type SHT_NOTE.

Parameters

Shdr the section to iterate over.
Err [out] an error to support fallible iteration, which should be checked after iteration ends.

Definition at line 526 of file ELF.h.

notes_begin() [1/2]

notes_begin() [2/2]

Get an iterator over notes in a section.

The section must be of type SHT_NOTE.

Parameters

Shdr the section to iterate over.
Err [out] an error to support fallible iteration, which should be checked after iteration ends.

Definition at line 481 of file ELF.h.

notes_end()

operator=()

program_headers()

relas()

relrs()

rels()

sections()

Definition at line 1002 of file ELF.h.

References llvm::ArrayRef(), base(), llvm::object::createError(), llvm::First, getHeader(), getShNum(), UINT64_MAX, and llvm::Twine::utohexstr().

Referenced by llvm::offloading::amdgpu::getAMDGPUMetaDataFromImage(), llvm::orc::getDynamicStrTab(), readBBAddrMapImpl(), and readDynsymVersionsImpl().

symbols()

toMappedAddr()

Definition at line 677 of file ELF.cpp.

References A(), B(), base(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::object::createError(), getBufSize(), I, llvm::is_sorted(), llvm::Offset, program_headers(), llvm::ELF::PT_LOAD, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::stable_sort(), llvm::upper_bound(), and llvm::Twine::utohexstr().

Referenced by llvm::orc::getDynamicStrTab(), and getDynSymtabSize().


The documentation for this class was generated from the following files: