LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
LIEF::ELF::Header Class Reference

Class which represents the ELF's header. This class mirrors the raw ELF Elfxx_Ehdr structure. More...

#include <Header.hpp>

Inheritance diagram for LIEF::ELF::Header:
Inheritance graph
[legend]
Collaboration diagram for LIEF::ELF::Header:
Collaboration graph
[legend]

Public Types

enum  {
  EI_MAG0 = 0 , EI_MAG1 = 1 , EI_MAG2 = 2 , EI_MAG3 = 3 ,
  EI_CLASS = 4 , EI_DATA = 5 , EI_VERSION = 6 , EI_OSABI = 7 ,
  EI_ABIVERSION = 8 , EI_PAD = 9 , EI_NIDENT = 16
}
 e_ident size and indices. More...
 
enum class  FILE_TYPE {
  NONE = 0 , REL = 1 , EXEC = 2 , DYN = 3 ,
  CORE = 4
}
 The type of the underlying ELF file. This enum matches the semantic of ET_NONE, ET_REL, ... More...
 
enum class  VERSION { NONE = 0 , CURRENT = 1 }
 Match the result of Elfxx_Ehdr.e_version More...
 
enum class  CLASS { NONE = 0 , ELF32 , ELF64 }
 Match the result of Elfxx_Ehdr.e_ident[EI_CLASS] More...
 
enum class  OS_ABI {
  SYSTEMV = 0 , HPUX = 1 , NETBSD = 2 , GNU = 3 ,
  LINUX = 3 , HURD = 4 , SOLARIS = 6 , AIX = 7 ,
  IRIX = 8 , FREEBSD = 9 , TRU64 = 10 , MODESTO = 11 ,
  OPENBSD = 12 , OPENVMS = 13 , NSK = 14 , AROS = 15 ,
  FENIXOS = 16 , CLOUDABI = 17 , C6000_ELFABI = 64 , AMDGPU_HSA = 64 ,
  C6000_LINUX = 65 , ARM = 97 , STANDALONE = 255
}
 Match the result Elfxx_Ehdr.e_ident[EI_OSABI] More...
 
enum class  ELF_DATA { NONE = 0 , LSB = 1 , MSB = 2 }
 Match the result Elfxx_Ehdr.e_ident[EI_DATA] More...
 
using identity_t = std::array<uint8_t, 16>
 
using abstract_architecture_t = std::pair<ARCHITECTURES, std::set<MODES>>
 
- Public Types inherited from LIEF::Object
template<class T >
using output_t = add_pointer_t<decay_t<T>>
 
template<class T >
using output_const_t = add_pointer_t<add_const_t<decay_t<T>>>
 

Public Member Functions

Headeroperator= (const Header &)=default
 
 Header (const Header &)=default
 
FILE_TYPE file_type () const
 Define the object file type. (e.g. executable, library...)
 
OBJECT_TYPES abstract_object_type () const
 LIEF abstract object type.
 
ARCH machine_type () const
 Target architecture.
 
abstract_architecture_t abstract_architecture () const
 LIEF abstract architecture.
 
ENDIANNESS abstract_endianness () const
 LIEF abstract endianness.
 
VERSION object_file_version () const
 Version of the object file format.
 
uint64_t entrypoint () const
 Executable entrypoint.
 
uint64_t program_headers_offset () const
 Offset of the programs table (also known as segments table)
 
uint64_t section_headers_offset () const
 Offset of the sections table.
 
uint32_t processor_flag () const
 Processor-specific flags.
 
uint32_t header_size () const
 Size of the current header (i.e. sizeof(Elfxx_Ehdr)) This size should be 64 for an ELF64 binary and 52 for an ELF32.
 
uint32_t program_header_size () const
 Return the size of a program header (i.e. sizeof(Elfxx_Phdr)) This size should be 56 for an ELF64 binary and 32 for an ELF32.
 
uint32_t numberof_segments () const
 Return the the number of segments.
 
uint32_t section_header_size () const
 Return the size of a section header (i.e. sizeof(Elfxx_Shdr)) This size should be 64 for a ELF64 binary and 40 for an ELF32.
 
uint32_t numberof_sections () const
 Return the number of sections.
 
uint32_t section_name_table_idx () const
 Return the section's index which contains sections' names.
 
identity_t & identity ()
 Return the ELF identity as an std::array
 
const identity_t & identity () const
 
CLASS identity_class () const
 Return the object's class. ELF64 or ELF32
 
ELF_DATA identity_data () const
 Specify the data encoding.
 
VERSION identity_version () const
 
OS_ABI identity_os_abi () const
 Identifies the version of the ABI for which the object is prepared.
 
uint32_t identity_abi_version () const
 ABI Version.
 
bool has (PROCESSOR_FLAGS flag) const
 
std::vector< PROCESSOR_FLAGS > flags_list () const
 
void file_type (FILE_TYPE type)
 
void machine_type (ARCH arch)
 
void object_file_version (VERSION version)
 
void entrypoint (uint64_t entry)
 
void program_headers_offset (uint64_t offset)
 
void section_headers_offset (uint64_t offset)
 
void processor_flag (uint32_t flags)
 
void header_size (uint32_t size)
 
void program_header_size (uint32_t size)
 
void numberof_segments (uint32_t n)
 
void section_header_size (uint32_t size)
 
void numberof_sections (uint32_t n)
 
void section_name_table_idx (uint32_t idx)
 
void identity (const std::string &identity)
 
void identity (const identity_t &identity)
 
void identity_class (CLASS cls)
 
void identity_data (ELF_DATA data)
 
void identity_version (VERSION version)
 
void identity_os_abi (OS_ABI osabi)
 
void identity_abi_version (uint8_t version)
 
void accept (Visitor &visitor) const override
 
- Public Member Functions inherited from LIEF::Object
 Object (const Object &other)
 
Objectoperator= (const Object &other)
 
template<class T >
output_t< T > as ()
 
template<class T >
output_const_t< T > as () const
 
virtual bool operator== (const Object &other) const
 
virtual bool operator!= (const Object &other) const
 

Detailed Description

Class which represents the ELF's header. This class mirrors the raw ELF Elfxx_Ehdr structure.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

e_ident size and indices.

Enumerator
EI_MAG0 

File identification index.

EI_MAG1 

File identification index.

EI_MAG2 

File identification index.

EI_MAG3 

File identification index.

EI_CLASS 

File class.

EI_DATA 

Data encoding.

EI_VERSION 

File version.

EI_OSABI 

OS/ABI identification.

EI_ABIVERSION 

ABI version.

EI_PAD 

Start of padding bytes.

EI_NIDENT 

Number of bytes in e_ident.

◆ CLASS

enum class LIEF::ELF::Header::CLASS
strong

Match the result of Elfxx_Ehdr.e_ident[EI_CLASS]

Enumerator
ELF32 

Invalid class.

ELF64 

32-bit objects

◆ ELF_DATA

enum class LIEF::ELF::Header::ELF_DATA
strong

Match the result Elfxx_Ehdr.e_ident[EI_DATA]

Enumerator
LSB 

Invalid data encoding.

MSB 

2's complement, little endian

◆ FILE_TYPE

enum class LIEF::ELF::Header::FILE_TYPE
strong

The type of the underlying ELF file. This enum matches the semantic of ET_NONE, ET_REL, ...

Enumerator
NONE 

Can't be determined.

REL 

Relocatable file (or object file)

EXEC 

non-pie executable

DYN 

Shared library or a pie-executable.

CORE 

Core dump file.

◆ OS_ABI

enum class LIEF::ELF::Header::OS_ABI
strong

Match the result Elfxx_Ehdr.e_ident[EI_OSABI]

Enumerator
HPUX 

UNIX System V ABI.

NETBSD 

HP-UX operating system.

GNU 

NetBSD.

LINUX 

GNU/Linux.

HURD 

Historical alias for ELFOSABI_GNU.

SOLARIS 

GNU/Hurd.

AIX 

Solaris.

IRIX 

AIX.

FREEBSD 

IRIX.

TRU64 

FreeBSD.

MODESTO 

TRU64 UNIX.

OPENBSD 

Novell Modesto.

OPENVMS 

OpenBSD.

NSK 

OpenVMS.

AROS 

Hewlett-Packard Non-Stop Kernel.

FENIXOS 

AROS.

CLOUDABI 

FenixOS.

C6000_ELFABI 

Nuxi CloudABI.

AMDGPU_HSA 

Bare-metal TMS320C6000.

C6000_LINUX 

AMD HSA runtime.

ARM 

Linux TMS320C6000.

STANDALONE 

ARM.

◆ VERSION

enum class LIEF::ELF::Header::VERSION
strong

Match the result of Elfxx_Ehdr.e_version

Enumerator
NONE 

Invalid ELF version.

CURRENT 

Current version (default)

Member Function Documentation

◆ accept()

void LIEF::ELF::Header::accept ( Visitor & visitor) const
overridevirtual

Implements LIEF::Object.

◆ identity_version()

VERSION LIEF::ELF::Header::identity_version ( ) const
inline

◆ numberof_sections()

uint32_t LIEF::ELF::Header::numberof_sections ( ) const
inline

Return the number of sections.

Warning
This value could differ from the real number of sections present in the binary. It must be taken as an indication

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