LLDB mainline
|
Generic representation of an ELF file header. More...
#include <ELFHeader.h>
Public Member Functions | |
ELFHeader () | |
bool | Is32Bit () const |
Returns true if this is a 32 bit ELF file header. | |
bool | Is64Bit () const |
Returns true if this is a 64 bit ELF file header. | |
lldb::ByteOrder | GetByteOrder () const |
The byte order of this ELF file header. | |
unsigned | GetRelocationJumpSlotType () const |
The jump slot relocation type of this ELF. | |
bool | HasHeaderExtension () const |
Check if there should be header extension in section header #0. | |
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. | |
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. | |
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. | |
Public Attributes | |
unsigned char | e_ident [llvm::ELF::EI_NIDENT] |
ELF file identification. | |
elf_addr | e_entry |
Virtual address program entry point. | |
elf_off | e_phoff |
File offset of program header table. | |
elf_off | e_shoff |
File offset of section header table. | |
elf_word | e_flags |
Processor specific flags. | |
elf_word | e_version |
Version of object file (always 1). | |
elf_half | e_type |
Object file type. | |
elf_half | e_machine |
Target architecture. | |
elf_half | e_ehsize |
Byte size of the ELF header. | |
elf_half | e_phentsize |
Size of a program header table entry. | |
elf_half | e_phnum_hdr |
Number of program header entries. | |
elf_half | e_shentsize |
Size of a section header table entry. | |
elf_half | e_shnum_hdr |
Number of section header entries. | |
elf_half | e_shstrndx_hdr |
String table section index. | |
elf_word | e_phnum |
Number of program header entries. | |
elf_word | e_shnum |
Number of section header entries. | |
elf_word | e_shstrndx |
String table section index. | |
Private Member Functions | |
void | ParseHeaderExtension (lldb_private::DataExtractor &data) |
Parse an ELFHeader header extension entry. | |
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.
ELFHeader::ELFHeader | ( | ) |
Definition at line 71 of file ELFHeader.cpp.
|
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.
Definition at line 161 of file ELFHeader.cpp.
Referenced by ObjectFileELF::CreateInstance().
ByteOrder ELFHeader::GetByteOrder | ( | ) | const |
The byte order of this ELF file header.
Definition at line 73 of file ELFHeader.cpp.
References e_ident, lldb::eByteOrderBig, lldb::eByteOrderInvalid, and lldb::eByteOrderLittle.
Referenced by Parse().
unsigned ELFHeader::GetRelocationJumpSlotType | ( | ) | const |
The jump slot relocation type of this ELF.
Definition at line 176 of file ELFHeader.cpp.
References e_machine.
Referenced by ParsePLTRelocations().
bool ELFHeader::HasHeaderExtension | ( | ) | const |
Check if there should be header extension in section header #0.
Definition at line 81 of file ELFHeader.cpp.
References e_phnum_hdr, e_shnum_hdr, e_shoff, and e_shstrndx_hdr.
Referenced by ObjectFileELF::GetModuleSpecifications(), and Parse().
|
inline |
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(), ObjectFileELF::CreateMemoryInstance(), Parse(), and ParsePLTRelocations().
|
inline |
Returns true if this is a 64 bit ELF file header.
Definition at line 93 of file ELFHeader.h.
References e_ident.
Referenced by ObjectFileELF::CreateMemoryInstance().
|
static |
Examines at most EI_NIDENT bytes starting from the given pointer and determines if the magic ELF identification exists.
Definition at line 157 of file ELFHeader.cpp.
Referenced by ObjectFileELF::CreateInstance(), ProcessElfCore::CreateInstance(), ObjectFileELF::CreateMemoryInstance(), ProcessElfCore::FindBuidIdInCoreMemory(), and ObjectFileELF::MagicBytesMatch().
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.
[in,out] | data | The DataExtractor to read from. Updated with the address size and byte order attributes appropriate to this header. |
[in,out] | offset | Pointer to an offset in the data. On return the offset will be advanced by the number of bytes read. |
Definition at line 114 of file ELFHeader.cpp.
References e_ehsize, e_entry, e_flags, e_ident, e_phnum, e_phnum_hdr, e_shnum, e_shnum_hdr, e_shstrndx, e_shstrndx_hdr, e_type, e_version, GetByteOrder(), GetMaxU64(), lldb_private::DataExtractor::GetU16(), lldb_private::DataExtractor::GetU32(), lldb_private::DataExtractor::GetU8(), HasHeaderExtension(), Is32Bit(), ParseHeaderExtension(), lldb_private::DataExtractor::SetAddressByteSize(), and lldb_private::DataExtractor::SetByteOrder().
Referenced by ProcessElfCore::CreateInstance(), ObjectFileELF::CreateMemoryInstance(), ProcessElfCore::FindBuidIdInCoreMemory(), ObjectFileELF::GetModuleSpecifications(), and ObjectFileELF::ParseHeader().
|
private |
Parse an ELFHeader header extension entry.
This method is called by Parse().
[in] | data | The DataExtractor to read from. |
Definition at line 96 of file ELFHeader.cpp.
References e_phnum, e_phnum_hdr, e_shentsize, e_shnum, e_shnum_hdr, e_shoff, e_shstrndx, e_shstrndx_hdr, elf::ELFSectionHeader::Parse(), elf::ELFSectionHeader::sh_info, elf::ELFSectionHeader::sh_link, and elf::ELFSectionHeader::sh_size.
Referenced by Parse().
elf_half elf::ELFHeader::e_ehsize |
Byte size of the ELF header.
Definition at line 65 of file ELFHeader.h.
Referenced by ObjectFileELF::DumpELFHeader(), and Parse().
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(), ObjectFileELF::IsExecutable(), and Parse().
elf_word elf::ELFHeader::e_flags |
Processor specific flags.
Definition at line 61 of file ELFHeader.h.
Referenced by ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetSectionHeaderInfo(), mipsVariantFromElfFlags(), and Parse().
unsigned char elf::ELFHeader::e_ident[llvm::ELF::EI_NIDENT] |
ELF file identification.
Definition at line 57 of file ELFHeader.h.
Referenced by ProcessElfCore::CreateInstance(), ObjectFileELF::DumpELFHeader(), GetByteOrder(), ObjectFileELF::GetByteOrder(), ObjectFileELF::GetModuleSpecifications(), ObjectFileELF::GetSectionHeaderInfo(), Is32Bit(), Is64Bit(), loongarchVariantFromElfFlags(), mipsVariantFromElfFlags(), Parse(), ppc64VariantFromElfFlags(), and riscvVariantFromElfFlags().
elf_half elf::ELFHeader::e_machine |
Target architecture.
Definition at line 64 of file ELFHeader.h.
Referenced by ObjectFileELF::ApplyRelocations(), ObjectFileELF::DumpELFDynamic(), ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetModuleSpecifications(), GetRelocationJumpSlotType(), ObjectFileELF::GetSectionHeaderInfo(), and subTypeFromElfHeader().
elf_half elf::ELFHeader::e_phentsize |
Size of a program header table entry.
Definition at line 66 of file ELFHeader.h.
Referenced by ObjectFileELF::CreateMemoryInstance(), ObjectFileELF::DumpELFHeader(), ProcessElfCore::FindBuidIdInCoreMemory(), and ObjectFileELF::GetProgramHeaderInfo().
elf_word elf::ELFHeader::e_phnum |
Number of program header entries.
Definition at line 75 of file ELFHeader.h.
Referenced by ObjectFileELF::CreateMemoryInstance(), ObjectFileELF::DumpELFHeader(), ProcessElfCore::FindBuidIdInCoreMemory(), ObjectFileELF::GetProgramHeaderInfo(), Parse(), and ParseHeaderExtension().
elf_half elf::ELFHeader::e_phnum_hdr |
Number of program header entries.
Definition at line 67 of file ELFHeader.h.
Referenced by HasHeaderExtension(), Parse(), and ParseHeaderExtension().
elf_off elf::ELFHeader::e_phoff |
File offset of program header table.
Definition at line 59 of file ELFHeader.h.
Referenced by ObjectFileELF::CreateMemoryInstance(), ObjectFileELF::DumpELFHeader(), ProcessElfCore::FindBuidIdInCoreMemory(), and ObjectFileELF::GetProgramHeaderInfo().
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(), ObjectFileELF::GetSectionHeaderInfo(), and ParseHeaderExtension().
elf_word elf::ELFHeader::e_shnum |
Number of section header entries.
Definition at line 76 of file ELFHeader.h.
Referenced by ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetSectionHeaderInfo(), Parse(), and ParseHeaderExtension().
elf_half elf::ELFHeader::e_shnum_hdr |
Number of section header entries.
Definition at line 69 of file ELFHeader.h.
Referenced by HasHeaderExtension(), Parse(), and ParseHeaderExtension().
elf_off elf::ELFHeader::e_shoff |
File offset of section header table.
Definition at line 60 of file ELFHeader.h.
Referenced by ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetSectionHeaderInfo(), HasHeaderExtension(), and ParseHeaderExtension().
elf_word elf::ELFHeader::e_shstrndx |
String table section index.
Definition at line 77 of file ELFHeader.h.
Referenced by ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetSectionHeaderInfo(), Parse(), and ParseHeaderExtension().
elf_half elf::ELFHeader::e_shstrndx_hdr |
String table section index.
Definition at line 70 of file ELFHeader.h.
Referenced by HasHeaderExtension(), Parse(), and ParseHeaderExtension().
elf_half elf::ELFHeader::e_type |
Object file type.
Definition at line 63 of file ELFHeader.h.
Referenced by ObjectFileELF::CalculateStrata(), ObjectFileELF::CalculateType(), ProcessElfCore::CreateInstance(), ObjectFileELF::DumpELFHeader(), ObjectFileELF::GetModuleSpecifications(), ObjectFileELF::IsExecutable(), mipsVariantFromElfFlags(), and Parse().
elf_word elf::ELFHeader::e_version |
Version of object file (always 1).
Definition at line 62 of file ELFHeader.h.
Referenced by ProcessElfCore::CreateInstance(), ObjectFileELF::DumpELFHeader(), and Parse().