LLDB  mainline
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
elf::ELFHeader Class Reference

#include <ELFHeader.h>

Collaboration diagram for elf::ELFHeader:
Collaboration graph
[legend]

Public Member Functions

 ELFHeader ()
 
bool Is32Bit () const
 Returns true if this is a 32 bit ELF file header. More...
 
bool Is64Bit () const
 Returns true if this is a 64 bit ELF file header. More...
 
lldb::ByteOrder GetByteOrder () const
 The byte order of this ELF file header. More...
 
unsigned GetRelocationJumpSlotType () const
 The jump slot relocation type of this ELF. More...
 
bool HasHeaderExtension () const
 Check if there should be header extension in section header #0. More...
 
bool Parse (lldb_private::DataExtractor &data, lldb::offset_t *offset)
 Parse an ELFHeader entry starting at position offset and update the data extractor with the address size and byte order attributes as defined by the header. More...
 

Static Public Member Functions

static bool MagicBytesMatch (const uint8_t *magic)
 Examines at most EI_NIDENT bytes starting from the given pointer and determines if the magic ELF identification exists. More...
 
static unsigned AddressSizeInBytes (const uint8_t *magic)
 Examines at most EI_NIDENT bytes starting from the given address and determines the address size of the underlying ELF file. More...
 

Public Attributes

unsigned char e_ident [llvm::ELF::EI_NIDENT]
 ELF file identification. More...
 
elf_addr e_entry
 Virtual address program entry point. More...
 
elf_off e_phoff
 File offset of program header table. More...
 
elf_off e_shoff
 File offset of section header table. More...
 
elf_word e_flags
 Processor specific flags. More...
 
elf_word e_version
 Version of object file (always 1). More...
 
elf_half e_type
 Object file type. More...
 
elf_half e_machine
 Target architecture. More...
 
elf_half e_ehsize
 Byte size of the ELF header. More...
 
elf_half e_phentsize
 Size of a program header table entry. More...
 
elf_half e_phnum_hdr
 Number of program header entries. More...
 
elf_half e_shentsize
 Size of a section header table entry. More...
 
elf_half e_shnum_hdr
 Number of section header entries. More...
 
elf_half e_shstrndx_hdr
 String table section index. More...
 
elf_word e_phnum
 Number of program header entries. More...
 
elf_word e_shnum
 Number of section header entries. More...
 
elf_word e_shstrndx
 String table section index. More...
 

Private Member Functions

void ParseHeaderExtension (lldb_private::DataExtractor &data)
 Parse an ELFHeader header extension entry. More...
 

Detailed Description

Generic representation of an ELF file header.

This object is used to identify the general attributes on an ELF file and to locate additional sections within the file.

Definition at line 56 of file ELFHeader.h.

Constructor & Destructor Documentation

◆ ELFHeader()

ELFHeader::ELFHeader ( )

Definition at line 71 of file ELFHeader.cpp.

Member Function Documentation

◆ AddressSizeInBytes()

unsigned ELFHeader::AddressSizeInBytes ( const uint8_t *  magic)
static

Examines at most EI_NIDENT bytes starting from the given address and determines the address size of the underlying ELF file.

This function should only be called on an pointer for which MagicBytesMatch returns true.

Returns
The number of bytes forming an address in the ELF file (either 4 or 8), else zero if the address size could not be determined.

Definition at line 161 of file ELFHeader.cpp.

◆ GetByteOrder()

ByteOrder ELFHeader::GetByteOrder ( ) const

The byte order of this ELF file header.

Returns
The byte order of this ELF file as described by the header.

Definition at line 73 of file ELFHeader.cpp.

References lldb::eByteOrderBig, lldb::eByteOrderInvalid, and lldb::eByteOrderLittle.

◆ GetRelocationJumpSlotType()

unsigned ELFHeader::GetRelocationJumpSlotType ( ) const

The jump slot relocation type of this ELF.

Definition at line 176 of file ELFHeader.cpp.

Referenced by ParsePLTRelocations().

◆ HasHeaderExtension()

bool ELFHeader::HasHeaderExtension ( ) const

Check if there should be header extension in section header #0.

Returns
True if parsing the ELFHeader requires reading header extension and false otherwise.

Definition at line 81 of file ELFHeader.cpp.

Referenced by ObjectFileELF::GetModuleSpecifications().

◆ Is32Bit()

bool elf::ELFHeader::Is32Bit ( ) const
inline

Returns true if this is a 32 bit ELF file header.

Returns
True if this is a 32 bit ELF file header.

Definition at line 85 of file ELFHeader.h.

References e_ident.

Referenced by ObjectFileELF::ApplyRelocations(), and ParsePLTRelocations().

◆ Is64Bit()

bool elf::ELFHeader::Is64Bit ( ) const
inline

Returns true if this is a 64 bit ELF file header.

Returns
True if this is a 64 bit ELF file header.

Definition at line 93 of file ELFHeader.h.

References e_ident.

◆ MagicBytesMatch()

bool ELFHeader::MagicBytesMatch ( const uint8_t *  magic)
static

Examines at most EI_NIDENT bytes starting from the given pointer and determines if the magic ELF identification exists.

Returns
True if the given sequence of bytes identifies an ELF file.

Definition at line 157 of file ELFHeader.cpp.

Referenced by ProcessElfCore::CreateInstance().

◆ Parse()

bool ELFHeader::Parse ( lldb_private::DataExtractor data,
lldb::offset_t offset 
)

Parse an ELFHeader entry starting at position offset and update the data extractor with the address size and byte order attributes as defined by the header.

Parameters
[in,out]dataThe DataExtractor to read from. Updated with the address size and byte order attributes appropriate to this header.
[in,out]offsetPointer to an offset in the data. On return the offset will be advanced by the number of bytes read.
Returns
True if the ELFHeader was successfully read and false otherwise.

Definition at line 114 of file ELFHeader.cpp.

References GetMaxU64(), lldb_private::DataExtractor::GetU16(), lldb_private::DataExtractor::GetU32(), lldb_private::DataExtractor::GetU8(), lldb_private::DataExtractor::SetAddressByteSize(), and lldb_private::DataExtractor::SetByteOrder().

Referenced by ProcessElfCore::CreateInstance(), ObjectFileELF::GetModuleSpecifications(), and ObjectFileELF::ParseHeader().

◆ ParseHeaderExtension()

void ELFHeader::ParseHeaderExtension ( lldb_private::DataExtractor data)
private

Parse an ELFHeader header extension entry.

This method is called by Parse().

Parameters
[in]dataThe DataExtractor to read from.

Definition at line 96 of file ELFHeader.cpp.

References elf::ELFSectionHeader::Parse(), elf::ELFSectionHeader::sh_info, elf::ELFSectionHeader::sh_link, and elf::ELFSectionHeader::sh_size.

Member Data Documentation

◆ e_ehsize

elf_half elf::ELFHeader::e_ehsize

Byte size of the ELF header.

Definition at line 65 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader().

◆ e_entry

elf_addr elf::ELFHeader::e_entry

Virtual address program entry point.

Definition at line 58 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetEntryPointAddress(), and ObjectFileELF::IsExecutable().

◆ e_flags

elf_word elf::ELFHeader::e_flags

Processor specific flags.

Definition at line 61 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetSectionHeaderInfo(), and mipsVariantFromElfFlags().

◆ e_ident

unsigned char elf::ELFHeader::e_ident[llvm::ELF::EI_NIDENT]

◆ e_machine

elf_half elf::ELFHeader::e_machine

◆ e_phentsize

elf_half elf::ELFHeader::e_phentsize

Size of a program header table entry.

Definition at line 66 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetProgramHeaderInfo().

◆ e_phnum

elf_word elf::ELFHeader::e_phnum

Number of program header entries.

Definition at line 75 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetProgramHeaderInfo().

◆ e_phnum_hdr

elf_half elf::ELFHeader::e_phnum_hdr

Number of program header entries.

Definition at line 67 of file ELFHeader.h.

◆ e_phoff

elf_off elf::ELFHeader::e_phoff

File offset of program header table.

Definition at line 59 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetProgramHeaderInfo().

◆ e_shentsize

elf_half elf::ELFHeader::e_shentsize

Size of a section header table entry.

Definition at line 68 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetSectionHeaderInfo().

◆ e_shnum

elf_word elf::ELFHeader::e_shnum

Number of section header entries.

Definition at line 76 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetSectionHeaderInfo().

◆ e_shnum_hdr

elf_half elf::ELFHeader::e_shnum_hdr

Number of section header entries.

Definition at line 69 of file ELFHeader.h.

◆ e_shoff

elf_off elf::ELFHeader::e_shoff

File offset of section header table.

Definition at line 60 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetSectionHeaderInfo().

◆ e_shstrndx

elf_word elf::ELFHeader::e_shstrndx

String table section index.

Definition at line 77 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader(), and ObjectFileELF::GetSectionHeaderInfo().

◆ e_shstrndx_hdr

elf_half elf::ELFHeader::e_shstrndx_hdr

String table section index.

Definition at line 70 of file ELFHeader.h.

◆ e_type

elf_half elf::ELFHeader::e_type

◆ e_version

elf_word elf::ELFHeader::e_version

Version of object file (always 1).

Definition at line 62 of file ELFHeader.h.

Referenced by ObjectFileELF::DumpELFHeader().


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