LLVM  13.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::object::ELFFile< ELFT > Class Template Reference

#include "llvm/Object/ELF.h"

Inheritance diagram for llvm::object::ELFFile< ELFT >:
Inheritance graph
[legend]

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< StringRefgetSymbolVersionByIndex (uint32_t SymbolVersionIndex, bool &IsDefault, SmallVector< Optional< VersionEntry >, 0 > &VersionMap, Optional< bool > IsSymHidden) const
 
Expected< StringRefgetStringTable (const Elf_Shdr &Section, WarningHandler WarnHandler=&defaultWarningHandler) const
 
Expected< StringRefgetStringTableForSymtab (const Elf_Shdr &Section) const
 
Expected< StringRefgetStringTableForSymtab (const Elf_Shdr &Section, Elf_Shdr_Range Sections) const
 
Expected< StringRefgetLinkAsStrtab (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< StringRefgetSectionStringTable (Elf_Shdr_Range Sections, WarningHandler WarnHandler=&defaultWarningHandler) const
 
Expected< uint32_tgetSectionIndex (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< StringRefgetSectionName (const Elf_Shdr &Section, WarningHandler WarnHandler=&defaultWarningHandler) const
 
Expected< StringRefgetSectionName (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< Elf_BBAddrMap > > decodeBBAddrMap (const Elf_Shdr &Sec) const
 

Static Public Member Functions

static Expected< ELFFilecreate (StringRef Object)
 

Detailed Description

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

Definition at line 98 of file ELF.h.

Member Typedef Documentation

◆ WarningHandler

template<class ELFT >
using llvm::object::ELFFile< ELFT >::WarningHandler = llvm::function_ref<Error(const Twine &Msg)>

Definition at line 179 of file ELF.h.

Member Function Documentation

◆ android_relas()

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

Definition at line 377 of file ELF.cpp.

◆ base()

template<class ELFT >
const uint8_t* llvm::object::ELFFile< ELFT >::base ( ) const
inline

◆ create()

template<class ELFT >
Expected< ELFFile< ELFT > > llvm::object::ELFFile< ELFT >::create ( StringRef  Object)
static

◆ decode_relrs()

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

Definition at line 299 of file ELF.cpp.

◆ decodeBBAddrMap()

template<class ELFT >
Expected< std::vector< typename ELFT::BBAddrMap > > ELFFile::decodeBBAddrMap ( const Elf_Shdr &  Sec) const

Definition at line 617 of file ELF.cpp.

◆ dynamicEntries()

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

Definition at line 514 of file ELF.cpp.

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

◆ end()

template<class ELFT >
const uint8_t* llvm::object::ELFFile< ELFT >::end ( ) const
inline

Definition at line 182 of file ELF.h.

◆ getBufSize()

template<class ELFT >
size_t llvm::object::ELFFile< ELFT >::getBufSize ( ) const
inline

◆ getDynamicTagAsString() [1/2]

template<class ELFT >
std::string ELFFile::getDynamicTagAsString ( uint64_t  Type) const

Definition at line 509 of file ELF.cpp.

◆ getDynamicTagAsString() [2/2]

template<class ELFT >
std::string ELFFile::getDynamicTagAsString ( unsigned  Arch,
uint64_t  Type 
) const

Definition at line 445 of file ELF.cpp.

◆ getDynSymtabSize()

template<class ELFT >
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 694 of file ELF.h.

◆ getEntry() [1/2]

template<class ELFT >
template<typename T >
Expected< const T * > llvm::object::ELFFile< ELFT >::getEntry ( const Elf_Shdr &  Section,
uint32_t  Entry 
) const

Definition at line 826 of file ELF.h.

◆ getEntry() [2/2]

template<class ELFT >
template<typename T >
Expected< const T * > llvm::object::ELFFile< ELFT >::getEntry ( uint32_t  Section,
uint32_t  Entry 
) const

Definition at line 816 of file ELF.h.

◆ getHeader()

template<class ELFT >
const Elf_Ehdr& llvm::object::ELFFile< ELFT >::getHeader ( ) const
inline

◆ getLinkAsStrtab()

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getLinkAsStrtab ( const typename ELFT::Shdr Sec) const

Definition at line 1144 of file ELF.h.

◆ getRelativeRelocationType()

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

Definition at line 585 of file ELF.h.

◆ getRelocationSymbol()

template<class ELFT >
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 628 of file ELF.h.

◆ getRelocationTypeName() [1/2]

template<class ELFT >
StringRef llvm::object::ELFFile< ELFT >::getRelocationTypeName ( uint32_t  Type) const

Definition at line 549 of file ELF.h.

◆ getRelocationTypeName() [2/2]

template<class ELFT >
void llvm::object::ELFFile< ELFT >::getRelocationTypeName ( uint32_t  Type,
SmallVectorImpl< char > &  Result 
) const

Definition at line 554 of file ELF.h.

◆ getSection() [1/3]

template<class ELFT >
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 449 of file ELF.h.

◆ getSection() [2/3]

template<class ELFT >
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 459 of file ELF.h.

◆ getSection() [3/3]

template<class ELFT >
Expected< const typename ELFT::Shdr * > llvm::object::ELFFile< ELFT >::getSection ( uint32_t  Index) const

Definition at line 1047 of file ELF.h.

◆ getSectionContents()

template<class ELFT >
Expected< ArrayRef< uint8_t > > llvm::object::ELFFile< ELFT >::getSectionContents ( const Elf_Shdr &  Sec) const

Definition at line 544 of file ELF.h.

◆ getSectionContentsAsArray()

template<class ELFT >
template<typename T >
Expected< ArrayRef< T > > llvm::object::ELFFile< ELFT >::getSectionContentsAsArray ( const Elf_Shdr &  Sec) const

Definition at line 488 of file ELF.h.

◆ getSectionIndex()

template<class ELFT >
Expected< uint32_t > llvm::object::ELFFile< ELFT >::getSectionIndex ( const Elf_Sym &  Sym,
Elf_Sym_Range  Syms,
DataRegion< Elf_Word >  ShndxTable 
) const

Definition at line 432 of file ELF.h.

◆ getSectionName() [1/2]

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSectionName ( const Elf_Shdr &  Section,
StringRef  DotShstrtab 
) const

Definition at line 1173 of file ELF.h.

◆ getSectionName() [2/2]

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSectionName ( const Elf_Shdr &  Section,
WarningHandler  WarnHandler = &defaultWarningHandler 
) const

Definition at line 1161 of file ELF.h.

◆ getSectionStringTable()

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSectionStringTable ( Elf_Shdr_Range  Sections,
WarningHandler  WarnHandler = &defaultWarningHandler 
) const

Definition at line 638 of file ELF.h.

◆ getSegmentContents()

template<class ELFT >
Expected< ArrayRef< uint8_t > > llvm::object::ELFFile< ELFT >::getSegmentContents ( const Elf_Phdr &  Phdr) const

Definition at line 524 of file ELF.h.

◆ getSHNDXTable() [1/2]

template<class ELFT >
Expected< ArrayRef< typename ELFT::Word > > llvm::object::ELFFile< ELFT >::getSHNDXTable ( const Elf_Shdr &  Section) const

Definition at line 1082 of file ELF.h.

◆ getSHNDXTable() [2/2]

template<class ELFT >
Expected< ArrayRef< typename ELFT::Word > > llvm::object::ELFFile< ELFT >::getSHNDXTable ( const Elf_Shdr &  Section,
Elf_Shdr_Range  Sections 
) const

Definition at line 1091 of file ELF.h.

◆ getStringTable()

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getStringTable ( const Elf_Shdr &  Section,
WarningHandler  WarnHandler = &defaultWarningHandler 
) const

Definition at line 1056 of file ELF.h.

◆ getStringTableForSymtab() [1/2]

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getStringTableForSymtab ( const Elf_Shdr &  Section) const

Definition at line 1120 of file ELF.h.

◆ getStringTableForSymtab() [2/2]

template<class ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getStringTableForSymtab ( const Elf_Shdr &  Section,
Elf_Shdr_Range  Sections 
) const

Definition at line 1129 of file ELF.h.

◆ getSymbol()

template<class ELFT >
Expected< const typename ELFT::Sym * > llvm::object::ELFFile< ELFT >::getSymbol ( const Elf_Shdr *  Sec,
uint32_t  Index 
) const

Definition at line 472 of file ELF.h.

◆ getSymbolVersionByIndex()

template<typename ELFT >
Expected< StringRef > llvm::object::ELFFile< ELFT >::getSymbolVersionByIndex ( uint32_t  SymbolVersionIndex,
bool &  IsDefault,
SmallVector< Optional< VersionEntry >, 0 > &  VersionMap,
Optional< bool >  IsSymHidden 
) const

Definition at line 843 of file ELF.h.

◆ getVersionDefinitions()

template<class ELFT >
Expected< std::vector< VerDef > > llvm::object::ELFFile< ELFT >::getVersionDefinitions ( const Elf_Shdr &  Sec) const

Definition at line 872 of file ELF.h.

◆ getVersionDependencies()

template<class ELFT >
Expected< std::vector< VerNeed > > llvm::object::ELFFile< ELFT >::getVersionDependencies ( const Elf_Shdr &  Sec,
WarningHandler  WarnHandler = &defaultWarningHandler 
) const

Definition at line 959 of file ELF.h.

◆ isLE()

template<class ELFT >
bool llvm::object::ELFFile< ELFT >::isLE ( ) const
inline

Definition at line 242 of file ELF.h.

Referenced by llvm::object::ELFFile< object::ELF64LE >::isMips64EL().

◆ isMips64EL()

template<class ELFT >
bool llvm::object::ELFFile< ELFT >::isMips64EL ( ) const
inline

Definition at line 251 of file ELF.h.

◆ isMipsELF64()

template<class ELFT >
bool llvm::object::ELFFile< ELFT >::isMipsELF64 ( ) const
inline

Definition at line 246 of file ELF.h.

Referenced by llvm::object::ELFFile< object::ELF64LE >::isMips64EL().

◆ loadVersionMap()

template<class ELFT >
Expected< SmallVector< Optional< VersionEntry >, 0 > > llvm::object::ELFFile< ELFT >::loadVersionMap ( const Elf_Shdr *  VerNeedSec,
const Elf_Shdr *  VerDefSec 
) const

Definition at line 591 of file ELF.h.

◆ notes() [1/2]

template<class ELFT >
iterator_range<Elf_Note_Iterator> llvm::object::ELFFile< ELFT >::notes ( const Elf_Phdr &  Phdr,
Error Err 
) const
inline

Get an iterator range over notes of a program header.

The program header must be of type PT_NOTE.

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

Definition at line 353 of file ELF.h.

◆ notes() [2/2]

template<class ELFT >
iterator_range<Elf_Note_Iterator> llvm::object::ELFFile< ELFT >::notes ( const Elf_Shdr &  Shdr,
Error Err 
) const
inline

Get an iterator range over notes of a section.

The section must be of type SHT_NOTE.

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

Definition at line 365 of file ELF.h.

◆ notes_begin() [1/2]

template<class ELFT >
Elf_Note_Iterator llvm::object::ELFFile< ELFT >::notes_begin ( const Elf_Phdr &  Phdr,
Error Err 
) const
inline

Get an iterator over notes in a program header.

The program header must be of type PT_NOTE.

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

Definition at line 310 of file ELF.h.

◆ notes_begin() [2/2]

template<class ELFT >
Elf_Note_Iterator llvm::object::ELFFile< ELFT >::notes_begin ( const Elf_Shdr &  Shdr,
Error Err 
) const
inline

Get an iterator over notes in a section.

The section must be of type SHT_NOTE.

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

Definition at line 329 of file ELF.h.

◆ notes_end()

template<class ELFT >
Elf_Note_Iterator llvm::object::ELFFile< ELFT >::notes_end ( ) const
inline

Get the end iterator for notes.

Definition at line 342 of file ELF.h.

◆ program_headers()

template<class ELFT >
Expected<Elf_Phdr_Range> llvm::object::ELFFile< ELFT >::program_headers ( ) const
inline

Iterate over program header table.

Definition at line 284 of file ELF.h.

Referenced by llvm::elfabi::buildStub(), and llvm::object::getPhdrIndexForError().

◆ relas()

template<class ELFT >
Expected<Elf_Rela_Range> llvm::object::ELFFile< ELFT >::relas ( const Elf_Shdr &  Sec) const
inline

Definition at line 267 of file ELF.h.

◆ relrs()

template<class ELFT >
Expected<Elf_Relr_Range> llvm::object::ELFFile< ELFT >::relrs ( const Elf_Shdr &  Sec) const
inline

Definition at line 275 of file ELF.h.

◆ rels()

template<class ELFT >
Expected<Elf_Rel_Range> llvm::object::ELFFile< ELFT >::rels ( const Elf_Shdr &  Sec) const
inline

Definition at line 271 of file ELF.h.

◆ sections()

template<class ELFT >
Expected< typename ELFT::ShdrRange > llvm::object::ELFFile< ELFT >::sections

◆ symbols()

template<class ELFT >
Expected<Elf_Sym_Range> llvm::object::ELFFile< ELFT >::symbols ( const Elf_Shdr *  Sec) const
inline

Definition at line 261 of file ELF.h.

◆ toMappedAddr()

template<class ELFT >
Expected< const uint8_t * > ELFFile::toMappedAddr ( uint64_t  VAddr,
WarningHandler  WarnHandler = &defaultWarningHandler 
) const

Definition at line 565 of file ELF.cpp.


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