ELF

Parser

class Parser : public LIEF::Parser

Class which parses and transforms an ELF file into a ELF::Binary object.

Subclassed by LIEF::OAT::Parser

Public Functions

Parser &operator=(const Parser&) = delete
Parser(const Parser&) = delete

Public Static Functions

static std::unique_ptr<Binary> parse(const std::string &file, const ParserConfig &conf = ParserConfig::all())

Parse an ELF file and return a LIEF::ELF::Binary object.

For weird binaries (e.g. sectionless) you can choose which method to use for counting dynamic symbols

Parameters:
  • file[in] Path to the ELF binary

  • conf[in] Optional configuration for the parser

Returns:

LIEF::ELF::Binary as a unique_ptr

static std::unique_ptr<Binary> parse(const std::vector<uint8_t> &data, const ParserConfig &conf = ParserConfig::all())

Parse the given raw data as an ELF binary and return a LIEF::ELF::Binary object.

For weird binaries (e.g. sectionless) you can choose which method use to count dynamic symbols

Parameters:
  • data[in] Raw ELF as a std::vector of uint8_t

  • conf[in] Optional configuration for the parser

Returns:

LIEF::ELF::Binary

static std::unique_ptr<Binary> parse(std::unique_ptr<BinaryStream> stream, const ParserConfig &conf = ParserConfig::all())

Parse the ELF binary from the given stream and return a LIEF::ELF::Binary object.

For weird binaries (e.g. sectionless) you can choose which method use to count dynamic symbols

Parameters:
  • stream[in] The stream which wraps the ELF binary

  • conf[in] Optional configuration for the parser

Returns:

LIEF::ELF::Binary

Public Static Attributes

static constexpr uint32_t NB_MAX_SYMBOLS = 1000000
static constexpr uint32_t DELTA_NB_SYMBOLS = 3000
static constexpr uint32_t NB_MAX_BUCKETS = NB_MAX_SYMBOLS
static constexpr uint32_t NB_MAX_CHAINS = 1000000
static constexpr uint32_t NB_MAX_SEGMENTS = 10000
static constexpr uint32_t NB_MAX_RELOCATIONS = 3000000
static constexpr uint32_t NB_MAX_DYNAMIC_ENTRIES = 1000
static constexpr uint32_t NB_MAX_MASKWORD = 512
static constexpr uint32_t MAX_SECTION_SIZE = 2_GB
static constexpr uint32_t MAX_SEGMENT_SIZE = 3_GB

Friends

friend class OAT::Parser
struct ParserConfig

This structure is used to tweak the ELF Parser (ELF::Parser)

Public Members

bool parse_relocations = true

Whether relocations (including plt-like relocations) should be parsed.

bool parse_dyn_symbols = true

Whether dynamic symbols (those from .dynsym) should be parsed.

bool parse_static_symbols = true

Whether debug symbols (those from .symtab) should be parsed.

bool parse_symbol_versions = true

Whether versioning symbols should be parsed.

bool parse_notes = true

Whether ELF notes information should be parsed.

bool parse_overlay = true

Whether the overlay data should be parsed.

DYNSYM_COUNT_METHODS count_mtd = DYNSYM_COUNT_METHODS::COUNT_AUTO

The method used to count the number of dynamic symbols

Public Static Functions

static inline ParserConfig all()

This returns a ParserConfig object configured to process all the ELF elements.


Binary

class Binary : public LIEF::Binary

Class which represents an ELF binary.

Subclassed by LIEF::OAT::Binary

Public Types

enum PHDR_RELOC

This enum describes the different ways to relocate the segments table.

Values:

enumerator AUTO = 0

Defer the choice of the layout to LIEF.

enumerator PIE_SHIFT

The content of the binary right after the segments table is shifted and the relocations are updated accordingly. This kind of shift only works with PIE binaries.

enumerator BSS_END

The new segments table is relocated right after the first bss-like segment.

enumerator BINARY_END

The new segments table is relocated at the end of the binary.

enumerator SEGMENT_GAP

The new segments table is relocated between two LOAD segments. This kind of relocation is only doable when there is an alignment enforcement.

using string_list_t = std::vector<std::string>
using notes_t = std::vector<std::unique_ptr<Note>>

Internal container for storing notes.

using it_notes = ref_iterator<notes_t&, Note*>

Iterator which outputs Note& object.

using it_const_notes = const_ref_iterator<const notes_t&, const Note*>

Iterator which outputs const Note& object.

using symbols_version_requirement_t = std::vector<std::unique_ptr<SymbolVersionRequirement>>

Internal container for storing SymbolVersionRequirement.

using it_symbols_version_requirement = ref_iterator<symbols_version_requirement_t&, SymbolVersionRequirement*>

Iterator which outputs SymbolVersionRequirement& object.

using it_const_symbols_version_requirement = const_ref_iterator<const symbols_version_requirement_t&, const SymbolVersionRequirement*>

Iterator which outputs const SymbolVersionRequirement& object.

using symbols_version_definition_t = std::vector<std::unique_ptr<SymbolVersionDefinition>>

Internal container for storing SymbolVersionDefinition.

using it_symbols_version_definition = ref_iterator<symbols_version_definition_t&, SymbolVersionDefinition*>

Iterator which outputs SymbolVersionDefinition& object.

using it_const_symbols_version_definition = const_ref_iterator<const symbols_version_definition_t&, const SymbolVersionDefinition*>

Iterator which outputs const SymbolVersionDefinition& object.

using segments_t = std::vector<std::unique_ptr<Segment>>

Internal container for storing ELF’s Segment.

using it_segments = ref_iterator<segments_t&, Segment*>

Iterator which outputs Segment& object.

using it_const_segments = const_ref_iterator<const segments_t&, const Segment*>

Iterator which outputs const Segment& object.

using dynamic_entries_t = std::vector<std::unique_ptr<DynamicEntry>>

Internal container for storing ELF’s DynamicEntry.

using it_dynamic_entries = ref_iterator<dynamic_entries_t&, DynamicEntry*>

Iterator which outputs DynamicEntry& object.

using it_const_dynamic_entries = const_ref_iterator<const dynamic_entries_t&, const DynamicEntry*>

Iterator which outputs const DynamicEntry& object.

using symbols_version_t = std::vector<std::unique_ptr<SymbolVersion>>

Internal container for storing ELF’s SymbolVersion.

using it_symbols_version = ref_iterator<symbols_version_t&, SymbolVersion*>

Iterator which outputs SymbolVersion& object.

using it_const_symbols_version = const_ref_iterator<const symbols_version_t&, const SymbolVersion*>

Iterator which outputs const SymbolVersion& object.

using relocations_t = std::vector<std::unique_ptr<Relocation>>

Internal container for storing ELF’s Relocation.

using it_pltgot_relocations = filter_iterator<relocations_t&, Relocation*>

Iterator which outputs plt/got Relocation& object.

using it_const_pltgot_relocations = const_filter_iterator<const relocations_t&, const Relocation*>

Iterator which outputs plt/got const Relocation& object.

using it_dynamic_relocations = filter_iterator<relocations_t&, Relocation*>

Iterator which outputs dynamic Relocation& object (not related to the PLT/GOT mechanism)

using it_const_dynamic_relocations = const_filter_iterator<const relocations_t&, const Relocation*>

Iterator which outputs dynamic const Relocation& object (not related to the PLT/GOT mechanism)

using it_object_relocations = filter_iterator<relocations_t&, Relocation*>

Iterator which outputs Relocation& object found in object files (.o)

using it_const_object_relocations = const_filter_iterator<const relocations_t&, const Relocation*>

Iterator which outputs const Relocation& object found in object files (.o)

using it_relocations = ref_iterator<relocations_t&, Relocation*>

Iterator which outputs Relocation& object.

using it_const_relocations = const_ref_iterator<const relocations_t&, const Relocation*>

Iterator which outputs const Relocation& object.

using symbols_t = std::vector<std::unique_ptr<Symbol>>

Internal container for storing ELF’s Symbol.

using it_dynamic_symbols = ref_iterator<symbols_t&, Symbol*>

Iterator which outputs the Dynamic Symbol& object.

using it_const_dynamic_symbols = const_ref_iterator<const symbols_t&, const Symbol*>

Iterator which outputs the Dynamic const Symbol& object.

using it_static_symbols = ref_iterator<symbols_t&, Symbol*>

Iterator which outputs the static/debug Symbol& object.

using it_const_static_symbols = const_ref_iterator<const symbols_t&, const Symbol*>

Iterator which outputs the static/debug const Symbol& object.

using it_symbols = ref_iterator<std::vector<Symbol*>>

Iterator which outputs static and dynamic Symbol& object.

using it_const_symbols = const_ref_iterator<std::vector<Symbol*>>

Iterator which outputs static and dynamic const Symbol& object.

using it_exported_symbols = filter_iterator<std::vector<Symbol*>>

Iterator which outputs exported Symbol& object.

using it_const_exported_symbols = const_filter_iterator<std::vector<Symbol*>>

Iterator which outputs exported const Symbol& object.

using it_imported_symbols = filter_iterator<std::vector<Symbol*>>

Iterator which outputs imported Symbol& object.

using it_const_imported_symbols = const_filter_iterator<std::vector<Symbol*>>

Iterator which outputs imported const Symbol& object.

using sections_t = std::vector<std::unique_ptr<Section>>

Internal container for storing ELF’s Section.

using it_sections = ref_iterator<sections_t&, Section*>

Iterator which outputs Section& object.

using it_const_sections = const_ref_iterator<const sections_t&, const Section*>

Iterator which outputs const Section& object.

Public Functions

Binary &operator=(const Binary&) = delete
Binary(const Binary &copy) = delete
ELF_CLASS type() const

Return binary’s class (ELF32 or ELF64)

Header &header()

Return Elf header .

const Header &header() const
uint64_t last_offset_section() const

Return the last offset used in binary according to sections table.

uint64_t last_offset_segment() const

Return the last offset used in binary according to segments table.

uint64_t next_virtual_address() const

Return the next virtual address available.

it_sections sections()

Return an iterator over the binary’s sections.

it_const_sections sections() const
virtual uint64_t entrypoint() const override

Return the binary’s entrypoint.

it_segments segments()

Return binary’s segments.

it_const_segments segments() const
it_dynamic_entries dynamic_entries()

Return binary’s dynamic entries.

it_const_dynamic_entries dynamic_entries() const
DynamicEntry &add(const DynamicEntry &entry)

Add the given dynamic entry and return the new entry.

Note &add(const Note &note)

Add the given note and return the created entry.

void remove(const DynamicEntry &entry)

Remove the given dynamic entry.

void remove(DYNAMIC_TAGS tag)

Remove all dynamic entries with the given tag.

void remove(const Section &section, bool clear = false)

Remove the given section. The clear parameter can be used to zeroize the original content beforehand.

Parameters:
  • section[in] The section to remove

  • clear[in] Whether zeroize the original content

void remove(const Note &note)

Remove the given note.

void remove(Note::TYPE type)

Remove all notes with the given type.

void remove(const Segment &seg)

Remove the given segment.

it_dynamic_symbols dynamic_symbols()

Return an iterator over the binary’s dynamic symbols The dynamic symbols are those located in the .dynsym section.

it_const_dynamic_symbols dynamic_symbols() const
it_exported_symbols exported_symbols()

Return symbols which are exported by the binary.

it_const_exported_symbols exported_symbols() const
it_imported_symbols imported_symbols()

Return symbols which are imported by the binary.

it_const_imported_symbols imported_symbols() const
it_static_symbols static_symbols()

Return statics symbols.

it_const_static_symbols static_symbols() const
it_symbols_version symbols_version()

Return the symbol versions.

it_const_symbols_version symbols_version() const
it_symbols_version_definition symbols_version_definition()

Return symbols version definition.

it_const_symbols_version_definition symbols_version_definition() const
it_symbols_version_requirement symbols_version_requirement()

Return Symbol version requirement.

it_const_symbols_version_requirement symbols_version_requirement() const
it_dynamic_relocations dynamic_relocations()

Return dynamic relocations.

it_const_dynamic_relocations dynamic_relocations() const
Relocation &add_dynamic_relocation(const Relocation &relocation)

Add a new dynamic relocation.

We consider a dynamic relocation as a relocation which is not plt-related

See: add_pltgot_relocation

Relocation &add_pltgot_relocation(const Relocation &relocation)

Add a .plt.got relocation. This kind of relocation is usually associated with a PLT stub that aims at resolving the underlying symbol.

See also: add_dynamic_relocation

Relocation *add_object_relocation(const Relocation &relocation, const Section &section)

Add relocation for object file (.o)

The first parameter is the section to add while the second parameter is the LIEF::ELF::Section associated with the relocation.

If there is an error, this function returns a nullptr. Otherwise, it returns the relocation added.

it_pltgot_relocations pltgot_relocations()

Return plt.got relocations.

it_const_pltgot_relocations pltgot_relocations() const
it_object_relocations object_relocations()

Return relocations used in an object file (*.o)

it_const_object_relocations object_relocations() const
it_relocations relocations()

Return all relocations present in the binary.

it_const_relocations relocations() const
const Relocation *get_relocation(uint64_t address) const

Return relocation associated with the given address. It returns a nullptr if it is not found.

Relocation *get_relocation(uint64_t address)
const Relocation *get_relocation(const Symbol &symbol) const

Return relocation associated with the given Symbol It returns a nullptr if it is not found.

Relocation *get_relocation(const Symbol &symbol)
const Relocation *get_relocation(const std::string &symbol_name) const

Return relocation associated with the given Symbol name It returns a nullptr if it is not found.

Relocation *get_relocation(const std::string &symbol_name)
bool use_gnu_hash() const

true if GNU hash is used

const GnuHash *gnu_hash() const

Return the GnuHash object in readonly If the ELF binary does not use the GNU hash table, return a nullptr.

bool use_sysv_hash() const

true if SYSV hash is used

const SysvHash *sysv_hash() const

Return the SysvHash object as a read-only object If the ELF binary does not use the legacy sysv hash table, return a nullptr.

bool has_section(const std::string &name) const

Check if a section with the given name exists in the binary.

bool has_section_with_offset(uint64_t offset) const

Check if a section that handles the given offset exists.

bool has_section_with_va(uint64_t va) const

Check if a section that handles the given virtual address exists.

Section *get_section(const std::string &name)

Return Section with the given name. If the section can’t be found, it returns a nullptr.

const Section *get_section(const std::string &name) const
Section *text_section()

Return the .text section. If the section can’t be found, it returns a nullptr.

Section *dynamic_section()

Return the .dynamic section. If the section can’t be found, it returns a nullptr.

Section *hash_section()

Return the hash section. If the section can’t be found, it returns a nullptr.

Section *static_symbols_section()

Return section which holds static symbols. If the section can’t be found, it returns a nullptr.

virtual uint64_t imagebase() const override

Return program image base. For instance 0x40000

To compute the image base, we look for the PT_PHDR segment header (phdr), and we return phdr->p_vaddr - phdr->p_offset

uint64_t virtual_size() const

Return the size of the mapped binary.

bool has_interpreter() const

Check if the binary uses a loader (also named linker or interpreter)

See also

interpreter

const std::string &interpreter() const

Return the ELF interpreter if any. (e.g. /lib64/ld-linux-x86-64.so.2) If the binary does not have an interpreter, it returns an empty string.

void interpreter(const std::string &interpreter)

Change the interpreter.

it_symbols symbols()

Return an iterator on both static and dynamic symbols.

it_const_symbols symbols() const
Symbol &export_symbol(const Symbol &symbol)

Export the given symbol and create it if it doesn’t exist.

Symbol &export_symbol(const std::string &symbol_name, uint64_t value = 0)

Export the symbol with the given name and create it if it doesn’t exist.

bool has_dynamic_symbol(const std::string &name) const

Check if the symbol with the given name exists in the dynamic symbols table.

const Symbol *get_dynamic_symbol(const std::string &name) const

Get the dynamic symbol from the given name. Return a nullptr if it can’t be found.

Symbol *get_dynamic_symbol(const std::string &name)
bool has_static_symbol(const std::string &name) const

Check if the symbol with the given name exists in the static symbol table.

const Symbol *get_static_symbol(const std::string &name) const

Get the static symbol from the given name Return a nullptr if it can’t be found.

Symbol *get_static_symbol(const std::string &name)
string_list_t strings(size_t min_size = 5) const

Return list of the strings used by the ELF binary.

Basically, this function looks for string in the .roadata section

void remove_symbol(const std::string &name)

Remove symbols with the given name in both:

  • dynamic symbols

  • static symbols

void remove_static_symbol(const std::string &name)

Remove static symbols with the given name.

void remove_static_symbol(Symbol *symbol)
void remove_dynamic_symbol(const std::string &name)

Remove dynamic symbols with the given name.

void remove_dynamic_symbol(Symbol *symbol)

Remove the given symbol from the dynamic symbols table.

As a side effect, it will remove any ELF::Relocation that refers to this symbol and the SymbolVersion (if any) associated with this symbol

virtual result<uint64_t> get_function_address(const std::string &func_name) const override

Return the address of the given function name.

result<uint64_t> get_function_address(const std::string &func_name, bool demangled) const

Return the address of the given function name.

Parameters:
  • func_name[in] The function’s name target

  • demangled[in] Use the demangled name

Section *add(const Section &section, bool loaded = true)

Add a new section in the binary.

This function requires a well-formed ELF binary

Parameters:
  • section[in] The section object to insert

  • loaded[in] Boolean value to indicate that section’s data must be loaded by a PT_LOAD segment

Returns:

The section added. The size and the virtual address might change.

Section *extend(const Section &section, uint64_t size)
Symbol &add_static_symbol(const Symbol &symbol)

Add a static symbol.

Symbol &add_dynamic_symbol(const Symbol &symbol, const SymbolVersion *version = nullptr)

Add a dynamic symbol with the associated SymbolVersion.

Symbol &add_exported_function(uint64_t address, const std::string &name = "")

Create a symbol for the function at the given address and export it.

DynamicEntryLibrary &add_library(const std::string &library_name)

Add a library as dependency.

void remove_library(const std::string &library_name)

Remove the given library from the dependencies.

DynamicEntryLibrary *get_library(const std::string &library_name)

Get the library object (DynamicEntryLibrary) from the given name If the library can’t be found, it returns a nullptr.

const DynamicEntryLibrary *get_library(const std::string &library_name) const

Get the library object (DynamicEntryLibrary) from the given name If the library can’t be found, it returns a nullptr.

bool has_library(const std::string &name) const

Check if the given library name exists in the current binary.

Segment *add(const Segment &segment, uint64_t base = 0)

Add a new segment in the binary.

The segment is inserted at the end

This function requires a well-formed ELF binary

Returns:

The segment added. Virtual address and File Offset might change.

Segment *replace(const Segment &new_segment, const Segment &original_segment, uint64_t base = 0)

Replace the segment given in 2nd parameter with the segment given in the first one and return the updated segment.

Warning

The original_segment is no longer valid after this function

Segment *extend(const Segment &segment, uint64_t size)
virtual void patch_address(uint64_t address, const std::vector<uint8_t> &patch_value, LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override

Patch the content at virtual address address with patch_value.

Parameters:
  • address[in] Address to patch

  • patch_value[in] Patch to apply

  • addr_type[in] Specify if the address should be used as an absolute virtual address or an RVA

virtual void patch_address(uint64_t address, uint64_t patch_value, size_t size = sizeof(uint64_t), LIEF::Binary::VA_TYPES addr_type = LIEF::Binary::VA_TYPES::AUTO) override

Patch the address with the given value.

Parameters:
  • address[in] Address to patch

  • patch_value[in] Patch to apply

  • size[in] Size of the value in bytes (1, 2, … 8)

  • addr_type[in] Specify if the address should be used as an absolute virtual address or an RVA

void patch_pltgot(const Symbol &symbol, uint64_t address)

Patch the imported symbol with the address

Parameters:
  • symbol[in] Imported symbol to patch

  • address[in] New address

void patch_pltgot(const std::string &symbol_name, uint64_t address)

Patch the imported symbol’s name with the address

Parameters:
  • symbol_name[in] Imported symbol’s name to patch

  • address[in] New address

void strip()

Strip the binary by removing static symbols.

virtual void remove_section(const std::string &name, bool clear = false) override

Remove a binary’s section.

Parameters:
  • name[in] The name of the section to remove

  • clear[in] Whether zeroize the original content

virtual void write(const std::string &filename) override

Reconstruct the binary object and write it in filename

This function assumes that the layout of the current ELF binary is correct (i.e. the binary can run).

Parameters:

filename – Path for the written ELF binary

void write(const std::string &filename, Builder::config_t config)

Reconstruct the binary object with the given config and write it in filename

This function assumes that the layout of the current ELF binary is correct (i.e. the binary can run).

Parameters:
  • filename – Path for the written ELF binary

  • configBuilder configuration

virtual void write(std::ostream &os) override

Reconstruct the binary object and write it in os stream.

This function assumes that the layout of the current ELF binary is correct (i.e. the binary can run).

Parameters:

os – Output stream for the written ELF binary

void write(std::ostream &os, Builder::config_t config)

Reconstruct the binary object with the given config and write it in os stream.

Parameters:
  • os – Output stream for the written ELF binary

  • configBuilder configuration

std::vector<uint8_t> raw()

Reconstruct the binary object and return its content as a byte vector.

result<uint64_t> virtual_address_to_offset(uint64_t virtual_address) const

Convert a virtual address to a file offset.

virtual result<uint64_t> offset_to_virtual_address(uint64_t offset, uint64_t slide = 0) const override

Convert the given offset into a virtual address.

Parameters:
  • offset[in] The offset to convert.

  • slide[in] If not 0, it will replace the default base address (if any)

virtual bool is_pie() const override

Check if the binary has been compiled with -fpie -pie flags.

To do so we check if there is a PT_INTERP segment and if the binary type is ET_DYN (Shared object)

virtual bool has_nx() const override

Check if the binary uses the NX protection (Non executable stack)

const Section *section_from_offset(uint64_t offset, bool skip_nobits = true) const

Return the ELF::Section from the given offset. Return a nullptr if a section can’t be found.

If skip_nobits is set (which is the case by default), this function won’t consider section for which the type is SHT_NOBITS (like .bss, .tbss, ...)

Section *section_from_offset(uint64_t offset, bool skip_nobits = true)
const Section *section_from_virtual_address(uint64_t address, bool skip_nobits = true) const

Return the ELF::Section from the given address. Return a nullptr if a section can’t be found.

If skip_nobits is set (which is the case by default), this function won’t consider section for which type is SHT_NOBITS (like .bss, .tbss, ...)

Section *section_from_virtual_address(uint64_t address, bool skip_nobits = true)
const Segment *segment_from_virtual_address(uint64_t address) const

Return the ELF::Segment from the given address. Return a nullptr if a segment can’t be found.

Segment *segment_from_virtual_address(uint64_t address)
const Segment *segment_from_virtual_address(SEGMENT_TYPES type, uint64_t address) const
Segment *segment_from_virtual_address(SEGMENT_TYPES type, uint64_t address)
const Segment *segment_from_offset(uint64_t offset) const

Return the ELF::Segment from the offset. Return a nullptr if a segment can’t be found.

Segment *segment_from_offset(uint64_t offset)
const DynamicEntry *get(DYNAMIC_TAGS tag) const

Return the first ELF::DynamicEntry associated with the given tag If the tag can’t be found, it returns a nullptr.

DynamicEntry *get(DYNAMIC_TAGS tag)
const Segment *get(SEGMENT_TYPES type) const

Return the first ELF::Segment associated with the given type. If a segment can’t be found, it returns a nullptr.

Segment *get(SEGMENT_TYPES type)
const Note *get(Note::TYPE type) const

Return the first ELF::Note associated with the given type If a note can’t be found, it returns a nullptr.

Note *get(Note::TYPE type)
const Section *get(ELF_SECTION_TYPES type) const

Return the first ELF::Section associated with the given type If a section can’t be found, it returns a nullptr.

Section *get(ELF_SECTION_TYPES type)
bool has(DYNAMIC_TAGS tag) const

Check if an ELF::DynamicEntry associated with the given tag exists.

bool has(SEGMENT_TYPES type) const

Check if ELF::Segment associated with the given type exists.

bool has(Note::TYPE type) const

Check if a ELF::Note associated with the given type exists.

bool has(ELF_SECTION_TYPES type) const

Check if a ELF::Section associated with the given type exists.

virtual span<const uint8_t> get_content_from_virtual_address(uint64_t virtual_address, uint64_t size, Binary::VA_TYPES addr_type = Binary::VA_TYPES::AUTO) const override

Return the content located at virtual address.

virtual void accept(LIEF::Visitor &visitor) const override

Method associated with the visitor pattern.

void permute_dynamic_symbols(const std::vector<size_t> &permutation)

Apply the given permutation on the dynamic symbols table.

virtual LIEF::Binary::functions_t ctor_functions() const override

List of binary constructors (typically, the functions located in the .init_array)

LIEF::Binary::functions_t dtor_functions() const

List of the binary destructors (typically, the functions located in the .fini_array)

LIEF::Binary::functions_t functions() const

List of the functions found the in the binary.

bool has_notes() const

true if the binary embeds notes

it_const_notes notes() const

Return an iterator over the ELF’s LIEF::ELF::Note.

See also

has_note

it_notes notes()
uint64_t eof_offset() const

Return the last offset used by the ELF binary according to both: the sections table and the segments table.

inline bool has_overlay() const

True if data are present at the end of the binary.

span<const uint8_t> overlay() const

Overlay data (if any)

void overlay(std::vector<uint8_t> overlay)

Function to set the overlay.

uint64_t relocate_phdr_table(PHDR_RELOC type)

Force relocating the segments table in a specific way.

This function can be used to enforce a specific relocation of the segments table.

Parameters:

type[in] The relocation type to apply

Returns:

The offset of the new segments table or 0 if it fails with the given method.

size_t hash(const std::string &name)
~Binary() override
virtual std::ostream &print(std::ostream &os) const override
Binary &operator+=(const DynamicEntry &entry)
Binary &operator+=(const Section &section)
Binary &operator+=(const Segment &segment)
Binary &operator+=(const Note &note)
Binary &operator-=(const DynamicEntry &entry)
Binary &operator-=(DYNAMIC_TAGS tag)
Binary &operator-=(const Note &note)
Binary &operator-=(Note::TYPE type)
Segment *operator[](SEGMENT_TYPES type)
const Segment *operator[](SEGMENT_TYPES type) const
DynamicEntry *operator[](DYNAMIC_TAGS tag)
const DynamicEntry *operator[](DYNAMIC_TAGS tag) const
Note *operator[](Note::TYPE type)
const Note *operator[](Note::TYPE type) const
Section *operator[](ELF_SECTION_TYPES type)
const Section *operator[](ELF_SECTION_TYPES type) const

Public Static Functions

static inline bool classof(const LIEF::Binary *bin)


Section

class Section : public LIEF::Section

Class wich represents an ELF Section.

Public Types

using segments_t = std::vector<Segment*>
using it_segments = ref_iterator<segments_t&>
using it_const_segments = const_ref_iterator<const segments_t&>

Public Functions

Section(const uint8_t *data, ELF_CLASS type)
Section(const details::Elf64_Shdr &header)
Section(const details::Elf32_Shdr &header)
Section(const std::string &name, ELF_SECTION_TYPES type = ELF_SECTION_TYPES::SHT_PROGBITS)
Section()
~Section() override
Section &operator=(Section other)
Section(const Section &other)
void swap(Section &other)
ELF_SECTION_TYPES type() const
virtual span<const uint8_t> content() const override

Section’s content.

virtual void content(const std::vector<uint8_t> &data) override

Set section content.

void content(std::vector<uint8_t> &&data)
uint64_t flags() const

Section flags LIEF::ELF::ELF_SECTION_FLAGS.

bool has(ELF_SECTION_FLAGS flag) const

True if the section has the given flag

Parameters:

flag[in] flag to test

bool has(const Segment &segment) const

True if the section is wrapped by the given Segment

std::set<ELF_SECTION_FLAGS> flags_list() const

Return section flags as a std::set

virtual uint64_t size() const override

section’s size (size in the binary, not the virtual size)

virtual void size(uint64_t size) override

Change the section size.

virtual void offset(uint64_t offset) override
virtual uint64_t offset() const override

Offset in the binary.

uint64_t file_offset() const

See also

offset

uint64_t original_size() const

Original size of the section’s data.

This value is used by the ELF::Builder to determines if it needs to be relocated to avoid an override of the data

uint64_t alignment() const

Section file alignment.

uint64_t information() const

Section information. This meaning of this value depends on the section’s type.

uint64_t entry_size() const

This function returns the size of an element in the case of a section that contains an array.

For instance, the .dynamic section contains an array of DynamicEntry. As the size of the raw C structure of this entry is 0x10 (sizeof(Elf64_Dyn)) in a ELF64, the entry_size is set to this value.

uint32_t link() const

Index to another section.

Section &clear(uint8_t value = 0)

Clear the content of the section with the given value

void add(ELF_SECTION_FLAGS flag)

Add the given ELF_SECTION_FLAGS.

void remove(ELF_SECTION_FLAGS flag)

Remove the given ELF_SECTION_FLAGS.

void type(ELF_SECTION_TYPES type)
void flags(uint64_t flags)
void clear_flags()
void file_offset(uint64_t offset)
void link(uint32_t link)
void information(uint32_t info)
void alignment(uint64_t alignment)
void entry_size(uint64_t entry_size)
it_segments segments()
it_const_segments segments() const
inline Section &as_frame()
inline bool is_frame() const
virtual void accept(Visitor &visitor) const override
Section &operator+=(ELF_SECTION_FLAGS c)
Section &operator-=(ELF_SECTION_FLAGS c)

Friends

friend std::ostream &operator<<(std::ostream &os, const Section &section)

Segment

class Segment : public LIEF::Object

Class which represents the ELF segments.

Public Types

using sections_t = std::vector<Section*>
using it_sections = ref_iterator<sections_t&>
using it_const_sections = const_ref_iterator<const sections_t&>

Public Functions

Segment()
Segment(const details::Elf64_Phdr &header)
Segment(const details::Elf32_Phdr &header)
~Segment() override
Segment &operator=(Segment other)
Segment(const Segment &other)
Segment &operator=(Segment&&)
Segment(Segment&&)
void swap(Segment &other)
SEGMENT_TYPES type() const

The segment’s type (LOAD, DYNAMIC, …)

ELF_SEGMENT_FLAGS flags() const

The flag permissions associated with this segment.

uint64_t file_offset() const

The file offset of the data associated with this segment.

uint64_t virtual_address() const

The virtual address of the segment.

uint64_t physical_address() const

The physical address of the segment. This value is not really relevant on systems like Linux or Android. On the other hand, Qualcomm trustlets might use this value.

Usually this value matches virtual_address

uint64_t physical_size() const

The file size of the data associated with this segment.

uint64_t virtual_size() const

The in-memory size of this segment. Usually, if the .bss segment is wrapped by this segment then, virtual_size is larger than physical_size.

uint64_t alignment() const

The offset alignment of the segment.

span<const uint8_t> content() const

The raw data associated with this segment.

bool has(ELF_SEGMENT_FLAGS flag) const

Check if the current segment has the given flag.

bool has(const Section &section) const

Check if the current segment wraps the given ELF::Section.

bool has(const std::string &section_name) const

Check if the current segment wraps the given section’s name.

void add(ELF_SEGMENT_FLAGS flag)

Append the given ELF_SEGMENT_FLAGS.

void remove(ELF_SEGMENT_FLAGS flag)

Remove the given ELF_SEGMENT_FLAGS.

void type(SEGMENT_TYPES type)
void flags(ELF_SEGMENT_FLAGS flags)
void clear_flags()
void file_offset(uint64_t file_offset)
void virtual_address(uint64_t virtual_address)
void physical_address(uint64_t physical_address)
void physical_size(uint64_t physical_size)
void virtual_size(uint64_t virtual_size)
void alignment(uint64_t alignment)
void content(std::vector<uint8_t> content)
template<typename T>
T get_content_value(size_t offset) const
template<typename T>
void set_content_value(size_t offset, T value)
size_t get_content_size() const
it_sections sections()

Iterator over the sections wrapped by this segment.

it_const_sections sections() const
virtual void accept(Visitor &visitor) const override
Segment &operator+=(ELF_SEGMENT_FLAGS flag)
Segment &operator-=(ELF_SEGMENT_FLAGS flag)

Public Static Functions

static result<Segment> from_raw(const uint8_t *ptr, size_t size)
static result<Segment> from_raw(const std::vector<uint8_t> &raw)

Friends

friend std::ostream &operator<<(std::ostream &os, const Segment &segment)

Dynamic Entry

class DynamicEntry : public LIEF::Object

Class which represents an entry in the dynamic table These entries are located in the .dynamic section or the PT_DYNAMIC segment.

Subclassed by LIEF::ELF::DynamicEntryArray, LIEF::ELF::DynamicEntryFlags, LIEF::ELF::DynamicEntryLibrary, LIEF::ELF::DynamicEntryRpath, LIEF::ELF::DynamicEntryRunPath, LIEF::ELF::DynamicSharedObject

Public Functions

DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry &operator=(const DynamicEntry&)
DynamicEntry(const DynamicEntry&)
~DynamicEntry() override
DYNAMIC_TAGS tag() const

Tag of the current entry. The most common tags are: DT_NEEDED, DT_INIT, …

uint64_t value() const

Return the entry’s value.

The meaning of the value strongly depends on the tag. It can be an offset, an index, a flag, …

void tag(DYNAMIC_TAGS tag)
void value(uint64_t value)
virtual void accept(Visitor &visitor) const override
virtual std::ostream &print(std::ostream &os) const

Friends

friend std::ostream &operator<<(std::ostream &os, const DynamicEntry &entry)

Dynamic Entry Library

class DynamicEntryLibrary : public LIEF::ELF::DynamicEntry

Class which represents a DT_NEEDED entry in the dynamic table.

This kind of entry is usually used to create library dependency.

Public Functions

DynamicEntryLibrary()
DynamicEntryLibrary(std::string name)
DynamicEntryLibrary &operator=(const DynamicEntryLibrary&)
DynamicEntryLibrary(const DynamicEntryLibrary&)
const std::string &name() const

Return the library associated with this entry (e.g. libc.so.6)

void name(const std::string &name)
virtual void accept(Visitor &visitor) const override
virtual std::ostream &print(std::ostream &os) const override
DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry(const DynamicEntry&)

Public Static Functions

static bool classof(const DynamicEntry *entry)

Dynamic Shared Object

class DynamicSharedObject : public LIEF::ELF::DynamicEntry

Class which represents a DT_SONAME entry in the dynamic table This kind of entry is usually used no name the original library.

This entry is not present for executable.

Public Functions

DynamicSharedObject()
DynamicSharedObject(std::string name)
DynamicSharedObject &operator=(const DynamicSharedObject&)
DynamicSharedObject(const DynamicSharedObject&)
const std::string &name() const

The actual name (e.g. libMyLib.so)

void name(const std::string &name)
virtual void accept(Visitor &visitor) const override
virtual std::ostream &print(std::ostream &os) const override
DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry(const DynamicEntry&)

Public Static Functions

static bool classof(const DynamicEntry *entry)

Dynamic Entry Run Path

class DynamicEntryRunPath : public LIEF::ELF::DynamicEntry

Class that represents a DT_RUNPATH wich is used by the loader to resolve libraries (DynamicEntryLibrary).

Public Functions

DynamicEntryRunPath()
DynamicEntryRunPath(std::string runpath)

Constructor from (run)path.

DynamicEntryRunPath(const std::vector<std::string> &paths)

Constructor from a list of paths.

DynamicEntryRunPath &operator=(const DynamicEntryRunPath&)
DynamicEntryRunPath(const DynamicEntryRunPath&)
const std::string &name() const

Runpath raw value.

void name(const std::string &name)
const std::string &runpath() const

Runpath raw value.

void runpath(const std::string &runpath)
std::vector<std::string> paths() const

Paths as a list.

void paths(const std::vector<std::string> &paths)
DynamicEntryRunPath &insert(size_t pos, const std::string &path)

Insert a path at the given position

DynamicEntryRunPath &append(const std::string &path)

Append the given path

DynamicEntryRunPath &remove(const std::string &path)

Remove the given path

DynamicEntryRunPath &operator+=(const std::string &path)
DynamicEntryRunPath &operator-=(const std::string &path)
virtual void accept(Visitor &visitor) const override
virtual std::ostream &print(std::ostream &os) const override
DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry(const DynamicEntry&)

Public Static Functions

static bool classof(const DynamicEntry *entry)

Public Static Attributes

static constexpr char delimiter = ':'

Dynamic Entry RPath

class DynamicEntryRpath : public LIEF::ELF::DynamicEntry

Class which represents a DT_RPATH entry. This attribute is deprecated (cf. man ld) in favour of DT_RUNPATH (See DynamicRunPath)

Public Functions

DynamicEntryRpath()
DynamicEntryRpath(std::string rpath)
DynamicEntryRpath(const std::vector<std::string> &paths)

Constructor from a list of paths.

DynamicEntryRpath &operator=(const DynamicEntryRpath&)
DynamicEntryRpath(const DynamicEntryRpath&)
const std::string &name() const

The actual rpath as a string.

void name(const std::string &name)
const std::string &rpath() const

The actual rpath as a string.

void rpath(const std::string &name)
std::vector<std::string> paths() const

Paths as a list.

void paths(const std::vector<std::string> &paths)
DynamicEntryRpath &insert(size_t pos, const std::string &path)

Insert a path at the given position

DynamicEntryRpath &append(const std::string &path)

Append the given path

DynamicEntryRpath &remove(const std::string &path)

Remove the given path

DynamicEntryRpath &operator+=(const std::string &path)
DynamicEntryRpath &operator-=(const std::string &path)
virtual void accept(Visitor &visitor) const override
virtual std::ostream &print(std::ostream &os) const override
DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry(const DynamicEntry&)

Public Static Functions

static bool classof(const DynamicEntry *entry)

Public Static Attributes

static constexpr char delimiter = ':'

Dynamic Entry Array

class DynamicEntryArray : public LIEF::ELF::DynamicEntry

Class that represent an Array in the dynamic table. This entry is associated with constructors:

  • DT_PREINIT_ARRAY

  • DT_INIT_ARRAY

  • DT_FINI_ARRAY

The underlying values are 64-bits integers to cover both: ELF32 and ELF64 binaries.

Public Types

using array_t = std::vector<uint64_t>

Public Functions

DynamicEntryArray()
DynamicEntryArray(DYNAMIC_TAGS tag, array_t array)
DynamicEntryArray &operator=(const DynamicEntryArray&)
DynamicEntryArray(const DynamicEntryArray&)
array_t &array()

Return the array values (list of pointer)

const array_t &array() const
void array(const array_t &array)
DynamicEntryArray &insert(size_t pos, uint64_t function)

Insert the given function at pos

DynamicEntryArray &append(uint64_t function)

Append the given function.

DynamicEntryArray &remove(uint64_t function)

Remove the given function.

size_t size() const

Number of function registred in this array.

DynamicEntryArray &operator+=(uint64_t value)
DynamicEntryArray &operator-=(uint64_t value)
const uint64_t &operator[](size_t idx) const
uint64_t &operator[](size_t idx)
virtual void accept(Visitor &visitor) const override
virtual std::ostream &print(std::ostream &os) const override
~DynamicEntryArray() override
DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry(const DynamicEntry&)

Public Static Functions

static bool classof(const DynamicEntry *entry)

Dynamic Entry Flags

class DynamicEntryFlags : public LIEF::ELF::DynamicEntry

Public Types

using flags_list_t = std::set<uint32_t>

Public Functions

DynamicEntryFlags()
DynamicEntryFlags &operator=(const DynamicEntryFlags&)
DynamicEntryFlags(const DynamicEntryFlags&)
bool has(DYNAMIC_FLAGS f) const

If the current entry has the given DYNAMIC_FLAGS.

bool has(DYNAMIC_FLAGS_1 f) const

If the current entry has the given DYNAMIC_FLAGS_1.

flags_list_t flags() const

Return flags as a list of integers.

void add(DYNAMIC_FLAGS f)

Add the given DYNAMIC_FLAGS.

void add(DYNAMIC_FLAGS_1 f)

Add the given DYNAMIC_FLAGS_1.

void remove(DYNAMIC_FLAGS f)

Remove the given DYNAMIC_FLAGS.

void remove(DYNAMIC_FLAGS_1 f)

Remove the given DYNAMIC_FLAGS_1.

DynamicEntryFlags &operator+=(DYNAMIC_FLAGS f)
DynamicEntryFlags &operator+=(DYNAMIC_FLAGS_1 f)
DynamicEntryFlags &operator-=(DYNAMIC_FLAGS f)
DynamicEntryFlags &operator-=(DYNAMIC_FLAGS_1 f)
virtual void accept(Visitor &visitor) const override

Method so that the visitor can visit us.

virtual std::ostream &print(std::ostream &os) const override
DynamicEntry(const details::Elf64_Dyn &header)
DynamicEntry(const details::Elf32_Dyn &header)
DynamicEntry()
DynamicEntry(DYNAMIC_TAGS tag, uint64_t value)
DynamicEntry(const DynamicEntry&)

Public Static Functions

static bool classof(const DynamicEntry *entry)

Relocations

class Relocation : public LIEF::Relocation

Class that represents an ELF relocation.

Public Functions

Relocation(const details::Elf32_Rel &header)
Relocation(const details::Elf32_Rela &header)
Relocation(const details::Elf64_Rel &header)
Relocation(const details::Elf64_Rela &header)
Relocation(uint64_t address, uint32_t type = 0, int64_t addend = 0, bool isRela = false)
template<class T, typename = typename std::enable_if<std::is_enum<T>::value>::type>
inline Relocation(uint64_t address, T type, int64_t addend = 0, bool isRela = false)
Relocation()
Relocation(ARCH arch)
~Relocation() override
Relocation &operator=(Relocation other)
Relocation(const Relocation &other)
void swap(Relocation &other)
int64_t addend() const

Additional value that can be involved in the relocation processing.

uint32_t type() const

Type of the relocation This type depends on the underlying architecture which can be accessed with architecture().

Depending on the architecture, it can return:

  • RELOC_x86_64

  • RELOC_i386

  • RELOC_POWERPC32

  • RELOC_POWERPC64

  • RELOC_AARCH64

  • RELOC_ARM

  • RELOC_MIPS

  • RELOC_HEXAGON

  • RELOC_SYSTEMZ

  • RELOC_SPARC

  • RELOC_LOONGARCH

bool is_rela() const

Check if the relocation uses the explicit addend() field (this is usually the case for 64 bits binaries)

bool is_rel() const

Check if the relocation uses the implicit added (i.e. not present in the ELF structure)

uint32_t info() const

Relocation info which contains for instance the symbol index.

ARCH architecture() const
RELOCATION_PURPOSES purpose() const
virtual size_t size() const override

Return the size (in bits) of the value associated with this relocation.

Return -1 if it fails

bool has_symbol() const

True if the current relocation is associated with a symbol.

Symbol *symbol()

Symbol associated with the relocation If no symbol is tied to this relocation, it returns a nullptr.

const Symbol *symbol() const
bool has_section() const

True if the relocation has an associated section.

Section *section()

The section to which the relocation applies. If no section to which the relocation applies is associtated to this relocation, it returns a nullptr.

const Section *section() const
Section *symbol_table()

The associated symbol table. If no symbol table section is associated with this relocation, it returns a nullptr.

const Section *symbol_table() const
void addend(int64_t addend)
void type(uint32_t type)
void purpose(RELOCATION_PURPOSES purpose)
void info(uint32_t v)
void symbol(Symbol *symbol)
void section(Section *section)
void symbol_table(Section *section)
virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const Relocation &entry)

Symbol

class Symbol : public LIEF::Symbol

Class which represents an ELF symbol.

Public Functions

Symbol(const details::Elf32_Sym &header, ARCH arch)
Symbol(const details::Elf64_Sym &header, ARCH arch)
Symbol(std::string name, ELF_SYMBOL_TYPES type = ELF_SYMBOL_TYPES::STT_NOTYPE, SYMBOL_BINDINGS binding = SYMBOL_BINDINGS::STB_WEAK, uint8_t other = 0, uint16_t shndx = 0, uint64_t value = 0, uint64_t size = 0)
Symbol()
~Symbol() override
Symbol &operator=(Symbol other)
Symbol(const Symbol &other)
void swap(Symbol &other)
ELF_SYMBOL_TYPES type() const

The symbol’s type provides a general classification for the associated entity.

SYMBOL_BINDINGS binding() const

The symbol’s binding determines the linkage visibility and behavior.

uint8_t information() const

This member specifies the symbol’s type and binding attributes.

uint8_t other() const

Alias for visibility()

uint16_t section_idx() const

ELF::Section index associated with the symbol.

ELF_SYMBOL_VISIBILITY visibility() const

Symbol visibility.

Section *section()

Section associated with the symbol or a nullptr if it does not exist.

inline virtual uint64_t value() const override

This member has slightly different interpretations:

  • In relocatable files, value holds alignment constraints for a symbol for which section index is SHN_COMMON

  • In relocatable files, value holds a section offset for a defined symbol. That is, value is an offset from the beginning of the section associated with this symbol.

  • In executable and shared object files, value holds a virtual address. To make these files’s symbols more useful for the dynamic linker, the section offset (file interpretation) gives way to a virtual address (memory interpretation) for which the section number is irrelevant.

inline virtual uint64_t size() const override

Symbol size.

Many symbols have associated sizes. For example, a data object’s size is the number of bytes contained in the object. This member holds 0 if the symbol has no size or an unknown size.

uint16_t shndx() const

bool has_version() const

Check if this symbols has a symbol version .

SymbolVersion *symbol_version()

Return the SymbolVersion associated with this symbol. If there is no symbol version, return a nullptr.

const SymbolVersion *symbol_version() const
std::string demangled_name() const

Symbol’s unmangled name. If not available, it returns an empty string.

void type(ELF_SYMBOL_TYPES type)
void binding(SYMBOL_BINDINGS binding)
void other(uint8_t other)
void visibility(ELF_SYMBOL_VISIBILITY visibility)
void information(uint8_t info)
void shndx(uint16_t idx)
inline virtual void value(uint64_t value) override
inline virtual void size(uint64_t size) override
inline void shndx(SYMBOL_SECTION_INDEX idx)
bool is_exported() const

Check if the current symbol is exported.

void set_exported(bool flag = true)

Set whether or not the symbol is exported.

bool is_imported() const

Check if the current symbol is imported.

void set_imported(bool flag = true)

Set whether or not the symbol is imported.

inline bool is_static() const

True if the symbol is a static one.

inline bool is_function() const

True if the symbol represent a function.

inline bool is_variable() const

True if the symbol represent a variable.

virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const Symbol &entry)

Symbol Version

class SymbolVersion : public LIEF::Object

Class which represents an entry defined in the DT_VERSYM dynamic entry.

Public Functions

SymbolVersion(uint16_t value)
SymbolVersion()
~SymbolVersion() override
SymbolVersion &operator=(const SymbolVersion&)
SymbolVersion(const SymbolVersion&)
uint16_t value() const

Value associated with the symbol.

If the given SymbolVersion hasn’t Auxiliary version:

  • 0 means Local

  • 1 means Global

bool has_auxiliary_version() const

Whether the current SymbolVersion has an auxiliary one.

SymbolVersionAux *symbol_version_auxiliary()

SymbolVersionAux associated with the current Version if any, or a nullptr.

const SymbolVersionAux *symbol_version_auxiliary() const
void symbol_version_auxiliary(SymbolVersionAuxRequirement &svauxr)

Set the version’s auxiliary requirement The given SymbolVersionAuxRequirement must be an existing reference in the ELF::Binary.

On can add a new SymbolVersionAuxRequirement by using SymbolVersionRequirement::add_aux_requirement

void value(uint16_t v)
virtual void accept(Visitor &visitor) const override

Public Static Functions

static SymbolVersion local()

Generate a local SymbolVersion.

static SymbolVersion global()

Generate a global SymbolVersion.

Friends

friend std::ostream &operator<<(std::ostream &os, const SymbolVersion &symv)

Symbol Version Auxiliary

class SymbolVersionAux : public LIEF::Object

Class which represents an Auxiliary Symbol version.

Subclassed by LIEF::ELF::SymbolVersionAuxRequirement

Public Functions

SymbolVersionAux(std::string name)
SymbolVersionAux()
~SymbolVersionAux() override
SymbolVersionAux &operator=(const SymbolVersionAux&)
SymbolVersionAux(const SymbolVersionAux&)
const std::string &name() const

Smybol’s aux name (e.g. GLIBC_2.2.5)

void name(const std::string &name)
virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const SymbolVersionAux &symAux)

Symbol Version Definition

class SymbolVersionDefinition : public LIEF::Object

Class which represents an entry defined in DT_VERDEF or .gnu.version_d

Public Types

using version_aux_t = std::vector<std::unique_ptr<SymbolVersionAux>>
using it_version_aux = ref_iterator<version_aux_t&, SymbolVersionAux*>
using it_const_version_aux = const_ref_iterator<const version_aux_t&, const SymbolVersionAux*>

Public Functions

SymbolVersionDefinition()
SymbolVersionDefinition(const details::Elf64_Verdef &header)
SymbolVersionDefinition(const details::Elf32_Verdef &header)
~SymbolVersionDefinition() override
SymbolVersionDefinition &operator=(SymbolVersionDefinition other)
SymbolVersionDefinition(const SymbolVersionDefinition &other)
void swap(SymbolVersionDefinition &other)
uint16_t version() const

Version revision.

This field should always have the value 1. It will be changed if the versioning implementation has to be changed in an incompatible way.

uint16_t flags() const

Version information.

uint16_t ndx() const

Version index.

Numeric value used as an index in the LIEF::ELF::SymbolVersion table

uint32_t hash() const

Hash value of the symbol’s name (using ELF hash function)

it_version_aux symbols_aux()

SymbolVersionAux entries.

it_const_version_aux symbols_aux() const
void version(uint16_t version)
void flags(uint16_t flags)
void hash(uint32_t hash)
virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const SymbolVersionDefinition &sym)

Symbol Version Requirement

class SymbolVersionRequirement : public LIEF::Object

Class which represents an entry in the DT_VERNEED or .gnu.version_r table.

Public Types

using aux_requirement_t = std::vector<std::unique_ptr<SymbolVersionAuxRequirement>>
using it_aux_requirement = ref_iterator<aux_requirement_t&, SymbolVersionAuxRequirement*>
using it_const_aux_requirement = const_ref_iterator<const aux_requirement_t&, const SymbolVersionAuxRequirement*>

Public Functions

SymbolVersionRequirement()
SymbolVersionRequirement(const details::Elf64_Verneed &header)
SymbolVersionRequirement(const details::Elf32_Verneed &header)
~SymbolVersionRequirement() override
SymbolVersionRequirement &operator=(SymbolVersionRequirement other)
SymbolVersionRequirement(const SymbolVersionRequirement &other)
void swap(SymbolVersionRequirement &other)
uint16_t version() const

Version revision.

This field should always have the value 1. It will be changed if the versioning implementation has to be changed in an incompatible way.

uint32_t cnt() const

Number of associated auxiliary entries.

it_aux_requirement auxiliary_symbols()

Auxiliary entries as an iterator over SymbolVersionAuxRequirement.

it_const_aux_requirement auxiliary_symbols() const
const std::string &name() const

Return the library name associated with this requirement (e.g. libc.so.6)

void version(uint16_t version)
void name(const std::string &name)
SymbolVersionAuxRequirement &add_aux_requirement(const SymbolVersionAuxRequirement &aux_requirement)

Add a version auxiliary requirement to the existing list.

virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const SymbolVersionRequirement &symr)

Symbol Version Auxiliary Requirement

class SymbolVersionAuxRequirement : public LIEF::ELF::SymbolVersionAux

Public Functions

SymbolVersionAuxRequirement(const details::Elf64_Vernaux &header)
SymbolVersionAuxRequirement(const details::Elf32_Vernaux &header)
SymbolVersionAuxRequirement()
SymbolVersionAuxRequirement &operator=(const SymbolVersionAuxRequirement&)
SymbolVersionAuxRequirement(const SymbolVersionAuxRequirement&)
~SymbolVersionAuxRequirement() override
uint32_t hash() const

Hash value of the dependency name (use ELF hashing function)

uint16_t flags() const

Bitmask of flags.

uint16_t other() const

It returns the unique version index for the file which is used in the version symbol table. If the highest bit (bit 15) is set this is a hidden symbol which cannot be referenced from outside the object.

void hash(uint32_t hash)
void flags(uint16_t flags)
void other(uint16_t other)
virtual void accept(Visitor &visitor) const override
const std::string &name() const

Smybol’s aux name (e.g. GLIBC_2.2.5)

void name(const std::string &name)

Friends

friend std::ostream &operator<<(std::ostream &os, const SymbolVersionAuxRequirement &symAux)

GNU Hash table

class GnuHash : public LIEF::Object

Class which provides a view over the GNU Hash implementation. Most of the fields are read-only since the values are re-computed by the LIEF::ELF::Builder.

Public Functions

GnuHash()
GnuHash(uint32_t symbol_idx, uint32_t shift2, std::vector<uint64_t> bloom_filters, std::vector<uint32_t> buckets, std::vector<uint32_t> hash_values = {})
GnuHash &operator=(const GnuHash &copy)
GnuHash(const GnuHash &copy)
GnuHash(GnuHash&&)
GnuHash &operator=(GnuHash&&)
~GnuHash() override
uint32_t nb_buckets() const

Return the number of buckets.

uint32_t symbol_index() const

Index of the first symbol in the dynamic symbols table which accessible with the hash table.

uint32_t shift2() const

Shift count used in the bloom filter.

uint32_t maskwords() const

Number of bloom filters used. It must be a power of 2.

const std::vector<uint64_t> &bloom_filters() const

Bloom filters.

const std::vector<uint32_t> &buckets() const

Hash buckets.

const std::vector<uint32_t> &hash_values() const

Hash values.

bool check_bloom_filter(uint32_t hash) const

Check if the given hash passes the bloom filter.

bool check_bucket(uint32_t hash) const

Check if the given hash passes the bucket filter.

bool check(const std::string &symbol_name) const

Check if the symbol probably exists. If the returned value is false you can assume at 100% that the symbol with the given name doesn’t exist. If true, you can’t do any assumption.

bool check(uint32_t hash) const

Check if the symbol associated with the given hash probably exists. If the returned value is false you can assume at 100% that the symbol doesn’t exists. If true you can’t do any assumption.

virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const GnuHash &gnuhash)

SYSV Hash table

class SysvHash : public LIEF::Object

Class which represents the SYSV hash for the symbols resolution.

References:

Public Functions

SysvHash()
SysvHash &operator=(const SysvHash &copy)
SysvHash(const SysvHash &copy)
SysvHash &operator=(SysvHash&&)
SysvHash(SysvHash&&)
~SysvHash() override
uint32_t nbucket() const

Return the number of buckets used.

uint32_t nchain() const

Return the number of chain used.

const std::vector<uint32_t> &buckets() const

Buckets values.

const std::vector<uint32_t> &chains() const

Chains values.

inline void nchain(uint32_t nb)
virtual void accept(Visitor &visitor) const override

Friends

friend std::ostream &operator<<(std::ostream &os, const SysvHash &sysvhash)

Note

class Note : public LIEF::Object

Class which represents an ELF note. This class can be instantiated using the static Note::create functions.

Subclassed by LIEF::ELF::AndroidIdent, LIEF::ELF::CoreAuxv, LIEF::ELF::CoreFile, LIEF::ELF::CorePrPsInfo, LIEF::ELF::CorePrStatus, LIEF::ELF::CoreSigInfo, LIEF::ELF::NoteAbi, LIEF::ELF::NoteGnuProperty

Public Types

enum class TYPE

LIEF representation of the ELF NT_ values.

Values:

enumerator UNKNOWN = 0
enumerator GNU_ABI_TAG

Match NT_GNU_ABI_TAG: Operating system (OS) ABI information.

See: NoteAbi

enumerator GNU_HWCAP

Match NT_HWCAP: Synthetic hardware capabilities information.

enumerator GNU_BUILD_ID

Match NT_GNU_BUILD_ID: Unique build ID as generated by the GNU ld.

enumerator GNU_GOLD_VERSION

Match NT_GNU_GOLD_VERSION: The version of gold used to link.

enumerator GNU_PROPERTY_TYPE_0

Match NT_GNU_PROPERTY_TYPE_0: Program property note, as described in “Linux Extensions to the gABI”.

enumerator GNU_BUILD_ATTRIBUTE_OPEN
enumerator GNU_BUILD_ATTRIBUTE_FUNC
enumerator CRASHPAD

Crashpad note used by the Chromium project.

enumerator CORE_PRSTATUS

Coredump that wraps the elf_prstatus structure.

enumerator CORE_FPREGSET
enumerator CORE_PRPSINFO

Coredump that wraps the elf_prpsinfo structure.

See: CorePrPsInfo

enumerator CORE_TASKSTRUCT
enumerator CORE_AUXV

Coredump that contains a copy of all the auxiliary vectors (auxv)

See: CoreAuxv

enumerator CORE_PSTATUS
enumerator CORE_FPREGS

Coredump that wraps the fpregset structure.

enumerator CORE_PSINFO

Coredump that wraps the psinfo structure.

enumerator CORE_LWPSTATUS
enumerator CORE_LWPSINFO
enumerator CORE_WIN32PSTATUS
enumerator CORE_FILE
enumerator CORE_PRXFPREG
enumerator CORE_SIGINFO
enumerator CORE_ARM_VFP
enumerator CORE_ARM_TLS
enumerator CORE_ARM_HW_BREAK
enumerator CORE_ARM_HW_WATCH
enumerator CORE_ARM_SYSTEM_CALL
enumerator CORE_ARM_SVE
enumerator CORE_ARM_PAC_MASK
enumerator CORE_ARM_PACA_KEYS
enumerator CORE_ARM_PACG_KEYS
enumerator CORE_TAGGED_ADDR_CTRL
enumerator CORE_PAC_ENABLED_KEYS
enumerator CORE_X86_TLS
enumerator CORE_X86_IOPERM
enumerator CORE_X86_XSTATE
enumerator CORE_X86_CET
enumerator ANDROID_IDENT

Note that is specific to Android and that describes information such as the NDK version or the SDK build number.

See AndroidIdent

enumerator ANDROID_MEMTAG
enumerator ANDROID_KUSER
enumerator GO_BUILDID

Note specific to Go binaries.

enumerator STAPSDT

Note for SystemTap probes.

using description_t = std::vector<uint8_t>

Container used to handle the description data.

Public Functions

Note &operator=(const Note &copy) = default
Note(const Note &copy) = default
~Note() override = default
inline virtual std::unique_ptr<Note> clone() const

Clone the current note and keep its polymorphic type.

inline const std::string &name() const

Return the name of the note (also known as ‘owner’ )

inline TYPE type() const

Return the type of the note. This type does not match the NT_ type value. For accessing the original NT_ value, check original_type()

inline uint32_t original_type() const

The original NT_xxx integer value. The meaning of this value likely depends on the owner of the note.

inline span<const uint8_t> description() const

Return the description associated with the note.

inline span<uint8_t> description()
inline void name(std::string name)
inline void description(description_t description)

Change the description of the note.

uint64_t size() const

Size of the raw note which includes padding.

virtual void dump(std::ostream &os) const
virtual void accept(Visitor &visitor) const override

Public Static Functions

static result<TYPE> convert_type(E_TYPE ftype, uint32_t type, const std::string &name)

Convert the raw integer note type into a TYPE according to the owner.

static result<const char*> type_to_section(TYPE type)

Try to determine the ELF section name associated with the TYPE provided in parameter.

static inline result<const char*> note_to_section(const Note &note)
static result<const char*> type_owner(TYPE type)

Try to determine the owner’s name of the TYPE provided in parameter.

static std::unique_ptr<Note> create(const std::string &name, uint32_t type, description_t description, E_TYPE ftype = E_TYPE::ET_NONE, ARCH arch = ARCH::EM_NONE, ELF_CLASS cls = ELF_CLASS::ELFCLASSNONE)

Create a new note from the given parameters. Additional information such as the architecture or the ELF class could be required for creating notes like Coredump notes.

static std::unique_ptr<Note> create(const std::string &name, TYPE type, description_t description, ARCH arch = ARCH::EM_NONE, ELF_CLASS cls = ELF_CLASS::ELFCLASSNONE)

Create a new note from the given parameters. Additional information such as the architecture or the ELF class could be required for creating notes like Coredump notes.

static std::unique_ptr<Note> create(BinaryStream &stream, E_TYPE ftype = E_TYPE::ET_NONE, ARCH arch = ARCH::EM_NONE, ELF_CLASS cls = ELF_CLASS::ELFCLASSNONE)

Create a new note from the given stream. Additional information such as the architecture or the ELF class could be required for creating notes like Coredump notes.

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Note &note)

Core PrPsInfo

class CorePrPsInfo : public LIEF::ELF::Note

Class representing the NT_PRPSINFO core note. This kind of note represents general information about the process.

Public Functions

inline CorePrPsInfo(ARCH arch, ELF_CLASS cls, std::string name, uint32_t type, description_t description)
inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

result<info_t> info() const

Return a elf_prpsinfo-like structure or an error if it can’t be parsed.

void info(const info_t &info)
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~CorePrPsInfo() override = default

Public Static Functions

static inline bool classof(const Note *note)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const CorePrPsInfo &note)
struct info_t

Public Functions

inline std::string filename_stripped() const

Initial part of the arguments.

Return the filename without the ending \x00

inline std::string args_stripped() const

Return the args without the ending \x00

Public Members

uint8_t state = 0
char sname = ' '

Numeric process state.

bool zombie = false

printable character representing state

uint8_t nice = 0

Whether the process is a zombie.

uint64_t flag = 0

Nice value.

uint32_t uid = 0

Process flag.

uint32_t gid = 0

Process user ID.

uint32_t pid = 0

Process group ID.

uint32_t ppid = 0

Process ID.

uint32_t pgrp = 0

Process parent ID.

uint32_t sid = 0

Process group.

std::string filename

Process session id.

std::string args

Filename of the executable.


Core File

class CoreFile : public LIEF::ELF::Note

Class representing a core NT_FILE which describes the mapped files of the process.

Public Types

using files_t = std::vector<entry_t>
using iterator = files_t::iterator
using const_iterator = files_t::const_iterator

Public Functions

CoreFile(ARCH arch, ELF_CLASS cls, std::string name, uint32_t type, Note::description_t description)
inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

inline uint64_t count() const

Number of coredump file entries.

inline const files_t &files() const

Coredump file entries.

inline iterator begin()
inline iterator end()
inline const_iterator begin() const
inline const_iterator end() const
void files(const files_t &file)
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~CoreFile() override = default

Public Static Functions

static inline bool classof(const Note *note)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const CoreFile &note)
struct entry_t

Core file entry.

Public Members

uint64_t start = 0
uint64_t end = 0

Start address of mapped file.

End address of mapped file

uint64_t file_ofs = 0

Offset (in core) of mapped file.

std::string path

Path of mapped file.

Friends

friend std::ostream &operator<<(std::ostream &os, const entry_t &entry)

Core PrStatus

class CorePrStatus : public LIEF::ELF::Note

Class representing core PrPsInfo object.

Public Functions

inline CorePrStatus(ARCH arch, ELF_CLASS cls, std::string name, uint32_t type, description_t description)
inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

pr_status_t status() const

Return the pr_status_t structure.

void status(const pr_status_t &status)
inline ARCH architecture() const
result<uint64_t> pc() const

The program counter or an error if not found.

result<uint64_t> sp() const

The stack pointer or an error if not found.

result<uint64_t> return_value() const

The value of the register that holds the return value according to the calling convention.

result<uint64_t> get(Registers::X86 reg) const

Get the value for the given X86 register or return an error.

result<uint64_t> get(Registers::X86_64 reg) const

Get the value for the given X86_64 register or return an error.

result<uint64_t> get(Registers::ARM reg) const

Get the value for the given ARM register or return an error.

result<uint64_t> get(Registers::AARCH64 reg) const

Get the value for the given AARCH64 register or return an error.

ok_error_t set(Registers::X86 reg, uint64_t value)
ok_error_t set(Registers::X86_64 reg, uint64_t value)
ok_error_t set(Registers::ARM reg, uint64_t value)
ok_error_t set(Registers::AARCH64 reg, uint64_t value)
std::vector<uint64_t> register_values() const

A list of the register values. This list is guarantee to be as long as the Registers::ARM::_COUNT or empty if it can’t be resolved. Thus, one can access a specific register with:

if (architecture() == ARCH::EM_AARCH64) {
  auto reg_vals = register_values()
  if (!reg_vals.empty()) {
    auto x20 = reg_vals[static_cast<size_t>(Register::AARCH64::X20)]
  }
}
inline result<uint64_t> operator[](Registers::X86 reg) const
inline result<uint64_t> operator[](Registers::X86_64 reg) const
inline result<uint64_t> operator[](Registers::ARM reg) const
inline result<uint64_t> operator[](Registers::AARCH64 reg) const
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~CorePrStatus() override = default

Public Static Functions

static inline bool classof(const Note *note)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const CorePrStatus &note)
struct pr_status_t

Public Members

siginfo_t info
uint16_t cursig = 0
uint16_t reserved = 0
uint64_t sigpend = 0
uint64_t sighold = 0
int32_t pid = 0
int32_t ppid = 0
int32_t pgrp = 0
int32_t sid = 0
timeval_t utime
timeval_t stime
timeval_t cutime
timeval_t cstime
struct Registers

Public Types

enum class X86

Register for the x86 architecture (ARCH::EM_386).

Values:

enumerator EBX = 0
enumerator ECX
enumerator EDX
enumerator ESI
enumerator EDI
enumerator EBP
enumerator EAX
enumerator DS
enumerator ES
enumerator FS
enumerator GS
enumerator ORIG_EAX
enumerator EIP
enumerator CS
enumerator EFLAGS
enumerator ESP
enumerator SS
enumerator _COUNT
enum class X86_64

Register for the x86-64 architecture (ARCH::EM_X86_64).

Values:

enumerator R15 = 0
enumerator R14
enumerator R13
enumerator R12
enumerator RBP
enumerator RBX
enumerator R11
enumerator R10
enumerator R9
enumerator R8
enumerator RAX
enumerator RCX
enumerator RDX
enumerator RSI
enumerator RDI
enumerator ORIG_RAX
enumerator RIP
enumerator CS
enumerator EFLAGS
enumerator RSP
enumerator SS
enumerator _COUNT
enum class ARM

Register for the ARM architecture (ARCH::EM_ARM).

Values:

enumerator R0 = 0
enumerator R1
enumerator R2
enumerator R3
enumerator R4
enumerator R5
enumerator R6
enumerator R7
enumerator R8
enumerator R9
enumerator R10
enumerator R11
enumerator R12
enumerator R13
enumerator R14
enumerator R15
enumerator CPSR
enumerator _COUNT
enum class AARCH64

Register for the AARCH64 architecture (ARCH::AARCH64).

Values:

enumerator X0 = 0
enumerator X1
enumerator X2
enumerator X3
enumerator X4
enumerator X5
enumerator X6
enumerator X7
enumerator X8
enumerator X9
enumerator X10
enumerator X11
enumerator X12
enumerator X13
enumerator X14
enumerator X15
enumerator X16
enumerator X17
enumerator X18
enumerator X19
enumerator X20
enumerator X21
enumerator X22
enumerator X23
enumerator X24
enumerator X25
enumerator X26
enumerator X27
enumerator X28
enumerator X29
enumerator X30
enumerator X31
enumerator PC
enumerator PSTATE
enumerator _COUNT
struct siginfo_t

Public Members

int32_t signo = 0
int32_t code = 0
int32_t err = 0
struct timeval_t

Public Members

uint64_t sec = 0
uint64_t usec = 0

Core Siginfo

class CoreSigInfo : public LIEF::ELF::Note

Class representing a core siginfo object.

Public Functions

inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

result<int32_t> signo() const

Signal number of an error if it can’t be resolved.

result<int32_t> sigcode() const

Signal code of an error if it can’t be resolved.

result<int32_t> sigerrno() const

Signal error number of an error if it can’t be resolved.

void signo(uint32_t value)
void sigcode(uint32_t value)
void sigerrno(uint32_t value)
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~CoreSigInfo() override = default

Public Static Functions

static inline bool classof(const Note *note)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const CoreSigInfo &note)

Core Auxiliary Vector

class CoreAuxv : public LIEF::ELF::Note

Class representing core auxv object.

Public Types

enum class TYPE

Values:

enumerator END = 0

End of vector

enumerator IGNORE

Entry should be ignored

enumerator EXECFD

File descriptor of program

enumerator PHDR

Program headers for program

enumerator PHENT

Size of program header entry

enumerator PHNUM

Number of program headers

enumerator PAGESZ

System page size

enumerator BASE

Base address of interpreter

enumerator FLAGS

Flags

enumerator ENTRY

Entry point of program

enumerator NOTELF

Program is not ELF

enumerator UID

Real uid

enumerator EUID

Effective uid

enumerator GID

Real gid

enumerator EGID

Effective gid

enumerator TGT_PLATFORM

String identifying platform.

enumerator HWCAP

Machine dependent hints about processor capabilities.

enumerator CLKTCK

Frequency of times()

enumerator FPUCW

Used FPU control word.

enumerator DCACHEBSIZE

Data cache block size.

enumerator ICACHEBSIZE

Instruction cache block size.

enumerator UCACHEBSIZE

Instruction cache block size.

enumerator IGNOREPPC

Entry should be ignored.

enumerator SECURE

Boolean, was exec setuid-like?.

enumerator BASE_PLATFORM

String identifying real platform

enumerator RANDOM

Address of 16 random bytes

enumerator HWCAP2

Extension of AT_HWCAP

enumerator EXECFN = 31

Filename of executable

enumerator SYSINFO

Filename of executable

enumerator SYSINFO_EHDR

Pointer to ELF header of system-supplied DSO.

Public Functions

inline CoreAuxv(ARCH arch, ELF_CLASS cls, std::string name, uint32_t type, description_t description)
inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

std::map<TYPE, uint64_t> values() const

A map of CoreAuxv::TYPE and the value.

result<uint64_t> get(TYPE type) const

Return the value associated with the provided TYPE or a lief_errors::not_found if the type is not present.

inline result<uint64_t> operator[](TYPE type) const
bool set(TYPE type, uint64_t value)
bool set(std::map<TYPE, uint64_t> values)
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~CoreAuxv() override = default

Public Static Functions

static inline bool classof(const Note *note)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const CoreAuxv &note)

Android Identity

class AndroidIdent : public LIEF::ELF::Note

Class representing the “.note.android.ident” section.

Public Functions

inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

uint32_t sdk_version() const

Target SDK version (or 0 if it can’t be resolved)

std::string ndk_version() const

NDK version used (or an empty string if it can’t be parsed)

std::string ndk_build_number() const

NDK build number (or an empty string if it can’t be parsed)

void sdk_version(uint32_t version)
void ndk_version(const std::string &ndk_version)
void ndk_build_number(const std::string &ndk_build_number)
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~AndroidIdent() override = default

Public Static Functions

static inline bool classof(const Note *note)
static inline constexpr size_t description_size()

Public Static Attributes

static constexpr size_t sdk_version_size = sizeof(uint32_t)
static constexpr size_t ndk_version_size = 64 * sizeof(char)
static constexpr size_t ndk_build_number_size = 64 * sizeof(char)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const AndroidIdent &note)

Note ABI

class NoteAbi : public LIEF::ELF::Note

Class that wraps the NT_GNU_ABI_TAG note.

Public Types

enum class ABI

ABI recognized by this note.

Values:

enumerator LINUX = 0
enumerator GNU
enumerator SOLARIS2
enumerator FREEBSD
enumerator NETBSD
enumerator SYLLABLE
enumerator NACL
using version_t = std::array<uint32_t, 3>

Version type: (Major, Minor, Patch)

Public Functions

inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

result<version_t> version() const

Return the version or an error if it can’t be parsed.

result<ABI> abi() const

Return the ABI or an error if it can’t be parsed.

void version(const version_t &version)
void version(ABI abi)
virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~NoteAbi() override = default
Note(const Note &copy) = default

Public Static Functions

static inline bool classof(const Note *note)
static inline constexpr uint8_t description_size()

Public Static Attributes

static constexpr size_t abi_offset = 0
static constexpr size_t abi_size = sizeof(uint32_t)
static constexpr size_t version_offset = abi_size
static constexpr size_t version_size = 3 * sizeof(uint32_t)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const NoteAbi &note)

Note Gnu Property

class NoteGnuProperty : public LIEF::ELF::Note

Class that wraps the NT_GNU_PROPERTY_TYPE_0 note.

Public Types

using properties_t = std::vector<std::unique_ptr<NoteGnuProperty::Property>>

Public Functions

inline NoteGnuProperty(ARCH arch, ELF_CLASS cls, std::string name, uint32_t type, description_t description)
inline virtual std::unique_ptr<Note> clone() const override

Clone the current note and keep its polymorphic type.

std::unique_ptr<NoteGnuProperty::Property> find(Property::TYPE type) const

Find the property with the given type or return a nullptr

properties_t properties() const

Return the properties as a list of Property.

virtual void dump(std::ostream &os) const override
virtual void accept(Visitor &visitor) const override
~NoteGnuProperty() override = default

Public Static Functions

static inline bool classof(const Note *note)

Friends

inline friend std::ostream &operator<<(std::ostream &os, const NoteGnuProperty &note)
class Property

This class wraps the different properties that can be used in a NT_GNU_PROPERTY_TYPE_0 note.

Subclassed by LIEF::ELF::AArch64Feature, LIEF::ELF::Generic, LIEF::ELF::Needed, LIEF::ELF::NoteNoCopyOnProtected, LIEF::ELF::StackSize, LIEF::ELF::X86Features, LIEF::ELF::X86ISA

Public Types

enum class TYPE

LIEF’s mirror types of the original GNU_PROPERTY_ values.

Values:

enumerator UNKNOWN = 0
enumerator GENERIC

Property that dont’ have special implementation.

enumerator AARCH64_FEATURES

Mirror of GNU_PROPERTY_AARCH64_FEATURE_1_AND

enumerator STACK_SIZE

Mirror of GNU_PROPERTY_STACK_SIZE

enumerator NO_COPY_ON_PROTECTED

Mirror of GNU_PROPERTY_NO_COPY_ON_PROTECTED

enumerator X86_ISA

Mirror of GNU_PROPERTY_X86_ISA_1_* and GNU_PROPERTY_X86_COMPAT_*

enumerator X86_FEATURE

Mirror of GNU_PROPERTY_X86_FEATURE_*

enumerator NEEDED

Public Functions

inline TYPE type() const

Return the LIEF’s mirror type of the note.

virtual void dump(std::ostream &os) const
virtual ~Property() = default

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Property &prop)

Generic

class Generic : public LIEF::ELF::NoteGnuProperty::Property

This class represents a property which doesn’t have a concrete LIEF implementation.

Public Functions

inline uint32_t type() const

The original raw type as an integer. This value might depends on the architecture and/or the file type.

~Generic() override = default

Public Static Functions

static inline bool classof(const NoteGnuProperty::Property *prop)
static inline std::unique_ptr<Generic> create(uint32_t raw_type)

AArch64 Feature

class AArch64Feature : public LIEF::ELF::NoteGnuProperty::Property

This class represents the GNU_PROPERTY_AARCH64_FEATURE_1_AND property.

Public Types

enum class FEATURE

Values:

enumerator UNKNOWN = 0
enumerator BTI

Support Branch Target Identification (BTI)

enumerator PAC

Support Pointer authentication (PAC)

Public Functions

inline const std::vector<FEATURE> &features() const

Return the list of the supported features.

virtual void dump(std::ostream &os) const override
~AArch64Feature() override = default

Public Static Functions

static inline bool classof(const NoteGnuProperty::Property *prop)
static std::unique_ptr<AArch64Feature> create(BinaryStream &stream)

No Copy on Protected

class NoteNoCopyOnProtected : public LIEF::ELF::NoteGnuProperty::Property

This class provides an interface over the GNU_PROPERTY_NO_COPY_ON_PROTECTED property. This property indicates that the linker shouldn’t copy relocations against protected symbols.

Public Functions

~NoteNoCopyOnProtected() override = default

Public Static Functions

static inline bool classof(const NoteGnuProperty::Property *prop)
static inline std::unique_ptr<NoteNoCopyOnProtected> create()

Stack Size

class StackSize : public LIEF::ELF::NoteGnuProperty::Property

This class provides an interface over the GNU_PROPERTY_STACK_SIZE property.

This property can be used by the loader to raise the stack limit.

Public Functions

inline uint64_t stack_size() const

The indicated stack size.

virtual void dump(std::ostream &os) const override
~StackSize() override = default

Public Static Functions

static inline bool classof(const NoteGnuProperty::Property *prop)
static inline std::unique_ptr<StackSize> create(uint64_t stack_size)

X86 Feature

class X86Features : public LIEF::ELF::NoteGnuProperty::Property

This class interfaces the different GNU_PROPERTY_X86_FEATURE_* properties which includes:

  • GNU_PROPERTY_X86_FEATURE_1_AND

  • GNU_PROPERTY_X86_FEATURE_2_USED

  • GNU_PROPERTY_X86_FEATURE_2_NEEDED

Public Types

enum class FLAG

Flag according to the _AND, _USED or _NEEDED suffixes.

Values:

enumerator NONE = 0

For the original GNU_PROPERTY_X86_FEATURE_1_AND property.

enumerator USED

For the original GNU_PROPERTY_X86_FEATURE_2_USED property.

enumerator NEEDED

For the original GNU_PROPERTY_X86_FEATURE_2_NEEDED property.

enum class FEATURE

Features provided by these different properties.

Values:

enumerator UNKNOWN = 0
enumerator IBT
enumerator SHSTK
enumerator LAM_U48
enumerator LAM_U57
enumerator X86
enumerator X87
enumerator MMX
enumerator XMM
enumerator YMM
enumerator ZMM
enumerator FXSR
enumerator XSAVE
enumerator XSAVEOPT
enumerator XSAVEC
enumerator TMM
enumerator MASK
using features_t = std::vector<std::pair<FLAG, FEATURE>>

List of the features as a pair of FLAG, FEATURE.

For instance, if the raw property is GNU_PROPERTY_X86_FEATURE_2_USED with a bitmask set to GNU_PROPERTY_X86_FEATURE_2_XSAVE, it generates the pair: FLAG::USED, FEATURE::XSAVE

Public Functions

inline const features_t &features() const

List of the features.

virtual void dump(std::ostream &os) const override
~X86Features() override = default

Public Static Functions

static inline bool classof(const NoteGnuProperty::Property *prop)
static std::unique_ptr<X86Features> create(uint32_t type, BinaryStream &stream)

X86 ISA

class X86ISA : public LIEF::ELF::NoteGnuProperty::Property

This class interfaces the different GNU_PROPERTY_X86_ISA_* properties which includes:

  • GNU_PROPERTY_X86_ISA_1_USED

  • GNU_PROPERTY_X86_ISA_1_NEEDED

  • GNU_PROPERTY_X86_COMPAT_ISA_1_USED

  • GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED

  • GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED

  • GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED

Public Types

enum class FLAG

Values:

enumerator NONE = 0
enumerator USED
enumerator NEEDED
enum class ISA

Values:

enumerator UNKNOWN = 0
enumerator BASELINE
enumerator V2
enumerator V3
enumerator V4
enumerator CMOV
enumerator FMA
enumerator I486
enumerator I586
enumerator I686
enumerator SSE
enumerator SSE2
enumerator SSE3
enumerator SSSE3
enumerator SSE4_1
enumerator SSE4_2
enumerator AVX
enumerator AVX2
enumerator AVX512F
enumerator AVX512CD
enumerator AVX512ER
enumerator AVX512PF
enumerator AVX512VL
enumerator AVX512DQ
enumerator AVX512BW
enumerator AVX512_4FMAPS
enumerator AVX512_4VNNIW
enumerator AVX512_BITALG
enumerator AVX512_IFMA
enumerator AVX512_VBMI
enumerator AVX512_VBMI2
enumerator AVX512_VNNI
enumerator AVX512_BF16
using values_t = std::vector<std::pair<FLAG, ISA>>

Public Functions

inline const values_t &values() const

List of the ISA values in this property.

~X86ISA() override = default
virtual void dump(std::ostream &os) const override

Public Static Functions

static inline bool classof(const NoteGnuProperty::Property *prop)
static std::unique_ptr<X86ISA> create(uint32_t type, BinaryStream &stream)

Builder

class Builder

Class which takes an ELF::Binary object and reconstructs a valid binary.

This interface assumes that the layout of input ELF binary is correct (i.e. the binary can run).

Public Functions

Builder(Binary &binary)
Builder() = delete
~Builder()
void build()

Perform the build of the provided ELF binary.

inline Builder &set_config(config_t conf)

Tweak the ELF builder with the provided config parameter.

inline config_t &config()
const std::vector<uint8_t> &get_build()

Return the built ELF binary as a byte vector.

void write(const std::string &filename) const

Write the built ELF binary in the filename given in parameter.

void write(std::ostream &os) const

Write the built ELF binary in the stream os given in parameter.

struct config_t

Configuration options to tweak the building process.

Public Members

bool dt_hash = true
bool dyn_str = true

Rebuild DT_HASH.

bool dynamic_section = true

Rebuild DT_STRTAB.

bool fini_array = true

Rebuild PT_DYNAMIC segment.

bool gnu_hash = true

Rebuild DT_FINI_ARRAY.

bool init_array = true

Rebuild DT_GNU_HASH.

bool interpreter = true

Rebuild DT_INIT_ARRAY.

bool jmprel = true

Rebuild PT_INTERPRETER.

bool notes = false

Rebuild DT_JMPREL.

bool preinit_array = true

Disable note building since it can break the default layout.

bool rela = true

Rebuild DT_PREINIT_ARRAY.

bool static_symtab = true

Rebuild DT_REL[A].

bool sym_verdef = true

Rebuild .symtab

bool sym_verneed = true

Rebuild DT_VERDEF.

bool sym_versym = true

Rebuild DT_VERNEED.

bool symtab = true

Rebuild DT_VERSYM.

bool force_relocate = false

Rebuild DT_SYMTAB.


Utilities

bool LIEF::ELF::is_elf(const std::string &file)

Check if the given file is an ELF one.

bool LIEF::ELF::is_elf(const std::vector<uint8_t> &raw)

check if the raw data is a ELF file


Enums

Architectures

enum class LIEF::ELF::ARCH : size_t

Machine architectures See current registered ELF machine architectures at: http://www.sco.com/developers/gabi/latest/ch4.eheader.html.

Values:

enumerator EM_NONE = 0

No machine

enumerator EM_M32 = 1

AT&T WE 32100

enumerator EM_SPARC = 2

SPARC

enumerator EM_386 = 3

Intel 386

enumerator EM_68K = 4

Motorola 68000

enumerator EM_88K = 5

Motorola 88000

enumerator EM_IAMCU = 6

Intel MCU

enumerator EM_860 = 7

Intel 80860

enumerator EM_MIPS = 8

MIPS R3000

enumerator EM_S370 = 9

IBM System/370

enumerator EM_MIPS_RS3_LE = 10

MIPS RS3000 Little-endian

enumerator EM_PARISC = 15

Hewlett-Packard PA-RISC

enumerator EM_VPP500 = 17

Fujitsu VPP500

enumerator EM_SPARC32PLUS = 18

Enhanced instruction set SPARC

enumerator EM_960 = 19

Intel 80960

enumerator EM_PPC = 20

PowerPC

enumerator EM_PPC64 = 21

PowerPC64

enumerator EM_S390 = 22

IBM System/390

enumerator EM_SPU = 23

IBM SPU/SPC

enumerator EM_V800 = 36

NEC V800

enumerator EM_FR20 = 37

Fujitsu FR20

enumerator EM_RH32 = 38

TRW RH-32

enumerator EM_RCE = 39

Motorola RCE

enumerator EM_ARM = 40

ARM

enumerator EM_ALPHA = 41

DEC Alpha

enumerator EM_SH = 42

Hitachi SH

enumerator EM_SPARCV9 = 43

SPARC V9

enumerator EM_TRICORE = 44

Siemens TriCore

enumerator EM_ARC = 45

Argonaut RISC Core

enumerator EM_H8_300 = 46

Hitachi H8/300

enumerator EM_H8_300H = 47

Hitachi H8/300H

enumerator EM_H8S = 48

Hitachi H8S

enumerator EM_H8_500 = 49

Hitachi H8/500

enumerator EM_IA_64 = 50

Intel IA-64 processor architecture

enumerator EM_MIPS_X = 51

Stanford MIPS-X

enumerator EM_COLDFIRE = 52

Motorola ColdFire

enumerator EM_68HC12 = 53

Motorola M68HC12

enumerator EM_MMA = 54

Fujitsu MMA Multimedia Accelerator

enumerator EM_PCP = 55

Siemens PCP

enumerator EM_NCPU = 56

Sony nCPU embedded RISC processor

enumerator EM_NDR1 = 57

Denso NDR1 microprocessor

enumerator EM_STARCORE = 58

Motorola Star*Core processor

enumerator EM_ME16 = 59

Toyota ME16 processor

enumerator EM_ST100 = 60

STMicroelectronics ST100 processor

enumerator EM_TINYJ = 61

Advanced Logic Corp. TinyJ embedded processor family

enumerator EM_X86_64 = 62

AMD x86-64 architecture

enumerator EM_PDSP = 63

Sony DSP Processor

enumerator EM_PDP10 = 64

Digital Equipment Corp. PDP-10

enumerator EM_PDP11 = 65

Digital Equipment Corp. PDP-11

enumerator EM_FX66 = 66

Siemens FX66 microcontroller

enumerator EM_ST9PLUS = 67

STMicroelectronics ST9+ 8/16 bit microcontroller

enumerator EM_ST7 = 68

STMicroelectronics ST7 8-bit microcontroller

enumerator EM_68HC16 = 69

Motorola MC68HC16 Microcontroller

enumerator EM_68HC11 = 70

Motorola MC68HC11 Microcontroller

enumerator EM_68HC08 = 71

Motorola MC68HC08 Microcontroller

enumerator EM_68HC05 = 72

Motorola MC68HC05 Microcontroller

enumerator EM_SVX = 73

Silicon Graphics SVx

enumerator EM_ST19 = 74

STMicroelectronics ST19 8-bit microcontroller

enumerator EM_VAX = 75

Digital VAX

enumerator EM_CRIS = 76

Axis Communications 32-bit embedded processor

enumerator EM_JAVELIN = 77

Infineon Technologies 32-bit embedded processor

enumerator EM_FIREPATH = 78

Element 14 64-bit DSP Processor

enumerator EM_ZSP = 79

LSI Logic 16-bit DSP Processor

enumerator EM_MMIX = 80

Donald Knuth’s educational 64-bit processor

enumerator EM_HUANY = 81

Harvard University machine-independent object files

enumerator EM_PRISM = 82

SiTera Prism

enumerator EM_AVR = 83

Atmel AVR 8-bit microcontroller

enumerator EM_FR30 = 84

Fujitsu FR30

enumerator EM_D10V = 85

Mitsubishi D10V

enumerator EM_D30V = 86

Mitsubishi D30V

enumerator EM_V850 = 87

NEC v850

enumerator EM_M32R = 88

Mitsubishi M32R

enumerator EM_MN10300 = 89

Matsushita MN10300

enumerator EM_MN10200 = 90

Matsushita MN10200

enumerator EM_PJ = 91

picoJava

enumerator EM_OPENRISC = 92

OpenRISC 32-bit embedded processor

enumerator EM_ARC_COMPACT = 93

ARC International ARCompact processor (old spelling/synonym: EM_ARC_A5)

enumerator EM_XTENSA = 94

Tensilica Xtensa Architecture

enumerator EM_VIDEOCORE = 95

Alphamosaic VideoCore processor

enumerator EM_TMM_GPP = 96

Thompson Multimedia General Purpose Processor

enumerator EM_NS32K = 97

National Semiconductor 32000 series

enumerator EM_TPC = 98

Tenor Network TPC processor

enumerator EM_SNP1K = 99

Trebia SNP 1000 processor

enumerator EM_ST200 = 100

STMicroelectronics (www.st.com) ST200

enumerator EM_IP2K = 101

Ubicom IP2xxx microcontroller family

enumerator EM_MAX = 102

MAX Processor

enumerator EM_CR = 103

National Semiconductor CompactRISC microprocessor

enumerator EM_F2MC16 = 104

Fujitsu F2MC16

enumerator EM_MSP430 = 105

Texas Instruments embedded microcontroller msp430

enumerator EM_BLACKFIN = 106

Analog Devices Blackfin (DSP) processor

enumerator EM_SE_C33 = 107

S1C33 Family of Seiko Epson processors

enumerator EM_SEP = 108

Sharp embedded microprocessor

enumerator EM_ARCA = 109

Arca RISC Microprocessor

enumerator EM_UNICORE = 110

Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University

enumerator EM_EXCESS = 111

eXcess: 16/32/64-bit configurable embedded CPU

enumerator EM_DXP = 112

Icera Semiconductor Inc. Deep Execution Processor

enumerator EM_ALTERA_NIOS2 = 113

Altera Nios II soft-core processor

enumerator EM_CRX = 114

National Semiconductor CompactRISC CRX

enumerator EM_XGATE = 115

Motorola XGATE embedded processor

enumerator EM_C166 = 116

Infineon C16x/XC16x processor

enumerator EM_M16C = 117

Renesas M16C series microprocessors

enumerator EM_DSPIC30F = 118

Microchip Technology dsPIC30F Digital Signal

enumerator EM_CE = 119

Freescale Communication Engine RISC core

enumerator EM_M32C = 120

Renesas M32C series microprocessors

enumerator EM_TSK3000 = 131

Altium TSK3000 core

enumerator EM_RS08 = 132

Freescale RS08 embedded processor

enumerator EM_SHARC = 133

Analog Devices SHARC family of 32-bit DSP

enumerator EM_ECOG2 = 134

Cyan Technology eCOG2 microprocessor

enumerator EM_SCORE7 = 135

Sunplus S+core7 RISC processor

enumerator EM_DSP24 = 136

New Japan Radio (NJR) 24-bit DSP Processor

enumerator EM_VIDEOCORE3 = 137

Broadcom VideoCore III processor

enumerator EM_LATTICEMICO32 = 138

RISC processor for Lattice FPGA architecture

enumerator EM_SE_C17 = 139

Seiko Epson C17 family

enumerator EM_TI_C6000 = 140

The Texas Instruments TMS320C6000 DSP family

enumerator EM_TI_C2000 = 141

The Texas Instruments TMS320C2000 DSP family

enumerator EM_TI_C5500 = 142

The Texas Instruments TMS320C55x DSP family

enumerator EM_MMDSP_PLUS = 160

STMicroelectronics 64bit VLIW Data Signal Processor

enumerator EM_CYPRESS_M8C = 161

Cypress M8C microprocessor

enumerator EM_R32C = 162

Renesas R32C series microprocessors

enumerator EM_TRIMEDIA = 163

NXP Semiconductors TriMedia architecture family

enumerator EM_HEXAGON = 164

Qualcomm Hexagon processor

enumerator EM_8051 = 165

Intel 8051 and variants

enumerator EM_STXP7X = 166

STMicroelectronics STxP7x family of configurable

enumerator EM_NDS32 = 167
enumerator EM_ECOG1 = 168

Cyan Technology eCOG1X family

enumerator EM_ECOG1X = 168

Cyan Technology eCOG1X family

enumerator EM_MAXQ30 = 169

Dallas Semiconductor MAXQ30 Core Micro-controllers

enumerator EM_XIMO16 = 170

New Japan Radio (NJR) 16-bit DSP Processor

enumerator EM_MANIK = 171

M2000 Reconfigurable RISC Microprocessor

enumerator EM_CRAYNV2 = 172

Cray Inc. NV2 vector architecture

enumerator EM_RX = 173

Renesas RX family

enumerator EM_METAG = 174

Imagination Technologies META processor

enumerator EM_MCST_ELBRUS = 175

MCST Elbrus general purpose hardware architecture

enumerator EM_ECOG16 = 176

Cyan Technology eCOG16 family

enumerator EM_CR16 = 177

National Semiconductor CompactRISC CR16 16-bit

enumerator EM_ETPU = 178

Freescale Extended Time Processing Unit

enumerator EM_SLE9X = 179

Infineon Technologies SLE9X core

enumerator EM_L10M = 180

Intel L10M

enumerator EM_K10M = 181

Intel K10M

enumerator EM_AARCH64 = 183

ARM AArch64

enumerator EM_AVR32 = 185

Atmel Corporation 32-bit microprocessor family

enumerator EM_STM8 = 186

STMicroeletronics STM8 8-bit microcontroller

enumerator EM_TILE64 = 187

Tilera TILE64 multicore architecture family

enumerator EM_TILEPRO = 188

Tilera TILEPro multicore architecture family

enumerator EM_CUDA = 190

NVIDIA CUDA architecture

enumerator EM_TILEGX = 191

Tilera TILE-Gx multicore architecture family

enumerator EM_CLOUDSHIELD = 192

CloudShield architecture family

enumerator EM_COREA_1ST = 193

KIPO-KAIST Core-A 1st generation processor family

enumerator EM_COREA_2ND = 194

KIPO-KAIST Core-A 2nd generation processor family

enumerator EM_ARC_COMPACT2 = 195

Synopsys ARCompact V2

enumerator EM_OPEN8 = 196

Open8 8-bit RISC soft processor core

enumerator EM_RL78 = 197

Renesas RL78 family

enumerator EM_VIDEOCORE5 = 198

Broadcom VideoCore V processor

enumerator EM_78KOR = 199

Renesas 78KOR family

enumerator EM_56800EX = 200

Freescale 56800EX Digital Signal Controller (DSC)

enumerator EM_BA1 = 201

Beyond BA1 CPU architecture

enumerator EM_BA2 = 202

Beyond BA2 CPU architecture

enumerator EM_XCORE = 203

XMOS xCORE processor family

enumerator EM_MCHP_PIC = 204

Microchip 8-bit PIC(r) family

enumerator EM_INTEL205 = 205

Reserved by Intel

enumerator EM_INTEL206 = 206

Reserved by Intel

enumerator EM_INTEL207 = 207

Reserved by Intel

enumerator EM_INTEL208 = 208

Reserved by Intel

enumerator EM_INTEL209 = 209

Reserved by Intel

enumerator EM_KM32 = 210

KM211 KM32 32-bit processor

enumerator EM_KMX32 = 211

KM211 KMX32 32-bit processor

enumerator EM_KMX16 = 212

KM211 KMX16 16-bit processor

enumerator EM_KMX8 = 213

KM211 KMX8 8-bit processor

enumerator EM_KVARC = 214

KM211 KVARC processor

enumerator EM_CDP = 215

Paneve CDP architecture family

enumerator EM_COGE = 216

Cognitive Smart Memory Processor

enumerator EM_COOL = 217

iCelero CoolEngine

enumerator EM_NORC = 218

Nanoradio Optimized RISC

enumerator EM_CSR_KALIMBA = 219

CSR Kalimba architecture family

enumerator EM_AMDGPU = 224

AMD GPU architecture

enumerator EM_RISCV = 243

RISC-V

enumerator EM_BPF = 247

eBPF Filter

enumerator EM_LOONGARCH = 258

LoongArch


Identity

enum class LIEF::ELF::IDENTITY : size_t

e_ident size and indices.

Values:

enumerator EI_MAG0 = 0

File identification index.

enumerator EI_MAG1 = 1

File identification index.

enumerator EI_MAG2 = 2

File identification index.

enumerator EI_MAG3 = 3

File identification index.

enumerator EI_CLASS = 4

File class.

enumerator EI_DATA = 5

Data encoding.

enumerator EI_VERSION = 6

File version.

enumerator EI_OSABI = 7

OS/ABI identification.

enumerator EI_ABIVERSION = 8

ABI version.

enumerator EI_PAD = 9

Start of padding bytes.

enumerator EI_NIDENT = 16

Number of bytes in e_ident.


Binary types

enum class LIEF::ELF::E_TYPE : size_t

Enum associated with e_type

Values:

enumerator ET_NONE = 0

No file type

enumerator ET_REL = 1

Relocatable file

enumerator ET_EXEC = 2

Executable file

enumerator ET_DYN = 3

Shared object file

enumerator ET_CORE = 4

Core file

enumerator ET_LOPROC = 0xff00

Beginning of processor-specific codes

enumerator ET_HIPROC = 0xffff

Processor-specific


Version

enum class LIEF::ELF::VERSION : size_t

Versioning

Values:

enumerator EV_NONE = 0
enumerator EV_CURRENT = 1

Default value


ELF Class

enum class LIEF::ELF::ELF_CLASS : size_t

Object file classes.

Values:

enumerator ELFCLASSNONE = 0

Unknown

enumerator ELFCLASS32 = 1

32-bit object file

enumerator ELFCLASS64 = 2

64-bit object file


ELF Data

enum class LIEF::ELF::ELF_DATA : size_t

Object file byte orderings.

Values:

enumerator ELFDATANONE = 0

Invalid data encoding.

enumerator ELFDATA2LSB = 1

Little-endian object file

enumerator ELFDATA2MSB = 2

Big-endian object file


ELF OS/ABI

enum class LIEF::ELF::OS_ABI : size_t

OS ABI identification.

Values:

enumerator ELFOSABI_SYSTEMV = 0

UNIX System V ABI

enumerator ELFOSABI_HPUX = 1

HP-UX operating system

enumerator ELFOSABI_NETBSD = 2

NetBSD

enumerator ELFOSABI_GNU = 3

GNU/Linux

enumerator ELFOSABI_LINUX = 3

Historical alias for ELFOSABI_GNU.

enumerator ELFOSABI_HURD = 4

GNU/Hurd

enumerator ELFOSABI_SOLARIS = 6

Solaris

enumerator ELFOSABI_AIX = 7

AIX

enumerator ELFOSABI_IRIX = 8

IRIX

enumerator ELFOSABI_FREEBSD = 9

FreeBSD

enumerator ELFOSABI_TRU64 = 10

TRU64 UNIX

enumerator ELFOSABI_MODESTO = 11

Novell Modesto

enumerator ELFOSABI_OPENBSD = 12

OpenBSD

enumerator ELFOSABI_OPENVMS = 13

OpenVMS

enumerator ELFOSABI_NSK = 14

Hewlett-Packard Non-Stop Kernel

enumerator ELFOSABI_AROS = 15

AROS

enumerator ELFOSABI_FENIXOS = 16

FenixOS

enumerator ELFOSABI_CLOUDABI = 17

Nuxi CloudABI

enumerator ELFOSABI_C6000_ELFABI = 64

Bare-metal TMS320C6000

enumerator ELFOSABI_AMDGPU_HSA = 64

AMD HSA runtime

enumerator ELFOSABI_C6000_LINUX = 65

Linux TMS320C6000

enumerator ELFOSABI_ARM = 97

ARM

enumerator ELFOSABI_STANDALONE = 255

Standalone (embedded) application


Symbol section index

enum class LIEF::ELF::SYMBOL_SECTION_INDEX : size_t

Special section indices.

Values:

enumerator SHN_UNDEF = 0

Undefined, missing, irrelevant, or meaningless

enumerator SHN_LORESERVE = 0xff00

Lowest reserved index

enumerator SHN_LOPROC = 0xff00

Lowest processor-specific index

enumerator SHN_HIPROC = 0xff1f

Highest processor-specific index

enumerator SHN_LOOS = 0xff20

Lowest operating system-specific index

enumerator SHN_HIOS = 0xff3f

Highest operating system-specific index

enumerator SHN_ABS = 0xfff1

Symbol has absolute value; does not need relocation

enumerator SHN_COMMON = 0xfff2

FORTRAN COMMON or C external global variables

enumerator SHN_XINDEX = 0xffff

Mark that the index is >= SHN_LORESERVE

enumerator SHN_HIRESERVE = 0xffff

Highest reserved index


Section types

enum class LIEF::ELF::ELF_SECTION_TYPES : size_t

Section types.

Values:

enumerator SHT_NULL = 0

No associated section (inactive entry).

enumerator SHT_PROGBITS = 1

Program-defined contents.

enumerator SHT_SYMTAB = 2

Symbol table.

enumerator SHT_STRTAB = 3

String table.

enumerator SHT_RELA = 4

Relocation entries; explicit addends.

enumerator SHT_HASH = 5

Symbol hash table.

enumerator SHT_DYNAMIC = 6

Information for dynamic linking.

enumerator SHT_NOTE = 7

Information about the file.

enumerator SHT_NOBITS = 8

Data occupies no space in the file.

enumerator SHT_REL = 9

Relocation entries; no explicit addends.

enumerator SHT_SHLIB = 10

Reserved.

enumerator SHT_DYNSYM = 11

Symbol table.

enumerator SHT_INIT_ARRAY = 14

Pointers to initialization functions.

enumerator SHT_FINI_ARRAY = 15

Pointers to termination functions.

enumerator SHT_PREINIT_ARRAY = 16

Pointers to pre-init functions.

enumerator SHT_GROUP = 17

Section group.

enumerator SHT_SYMTAB_SHNDX = 18

Indices for SHN_XINDEX entries.

enumerator SHT_LOOS = 0x60000000

Lowest operating system-specific type.

enumerator SHT_ANDROID_REL = 0x60000001

Packed relocations (Android specific).

enumerator SHT_ANDROID_RELA = 0x60000002

Packed relocations (Android specific).

enumerator SHT_LLVM_ADDRSIG = 0x6fff4c03

This section is used to mark symbols as address-significant.

enumerator SHT_RELR = 0x6fffff00

New relr relocations (Android specific).

enumerator SHT_GNU_ATTRIBUTES = 0x6ffffff5

Object attributes.

enumerator SHT_GNU_HASH = 0x6ffffff6

GNU-style hash table.

enumerator SHT_GNU_verdef = 0x6ffffffd

GNU version definitions.

enumerator SHT_GNU_verneed = 0x6ffffffe

GNU version references.

enumerator SHT_GNU_versym = 0x6fffffff

GNU symbol versions table.

enumerator SHT_HIOS = 0x6fffffff

Highest operating system-specific type.

enumerator SHT_LOPROC = 0x70000000

Lowest processor arch-specific type.

enumerator SHT_ARM_EXIDX = 0x70000001U

Exception Index table

enumerator SHT_ARM_PREEMPTMAP = 0x70000002U

BPABI DLL dynamic linking pre-emption map

enumerator SHT_ARM_ATTRIBUTES = 0x70000003U

Object file compatibility attributes

enumerator SHT_ARM_DEBUGOVERLAY = 0x70000004U
enumerator SHT_ARM_OVERLAYSECTION = 0x70000005U
enumerator SHT_HEX_ORDERED = 0x70000000

Link editor is to sort the entries in

enumerator SHT_X86_64_UNWIND = 0x70000001

Unwind information

enumerator SHT_MIPS_REGINFO = 0x70000006

Register usage information

enumerator SHT_MIPS_OPTIONS = 0x7000000d

General options

enumerator SHT_MIPS_ABIFLAGS = 0x7000002a

ABI information.

enumerator SHT_HIPROC = 0x7fffffff

Highest processor arch-specific type.

enumerator SHT_LOUSER = 0x80000000

Lowest type reserved for applications.

enumerator SHT_HIUSER = 0xffffffff

Highest type reserved for applications.


Section flags

enum class LIEF::ELF::ELF_SECTION_FLAGS : size_t

Section flags.

Values:

enumerator SHF_NONE = 0x0
enumerator SHF_WRITE = 0x1

Section data should be writable during execution.

enumerator SHF_ALLOC = 0x2

Section occupies memory during program execution.

enumerator SHF_EXECINSTR = 0x4

Section contains executable machine instructions.

enumerator SHF_MERGE = 0x10

The data in this section may be merged.

enumerator SHF_STRINGS = 0x20

The data in this section is null-terminated strings.

enumerator SHF_INFO_LINK = 0x40U

A field in this section holds a section header table index.

Adds special ordering requirements for link editors.

enumerator SHF_OS_NONCONFORMING = 0x100U

This section requires special OS-specific processing to avoid incorrect behavior

enumerator SHF_GROUP = 0x200U

This section is a member of a section group.

enumerator SHF_TLS = 0x400U

This section holds Thread-Local Storage.

enumerator SHF_EXCLUDE = 0x80000000U

This section is excluded from the final executable or shared library.

enumerator XCORE_SHF_CP_SECTION = 0x800U
enumerator XCORE_SHF_DP_SECTION = 0x1000U
enumerator SHF_MASKOS = 0x0ff00000
enumerator SHF_MASKPROC = 0xf0000000

Bits indicating processor-specific flags.

enumerator SHF_X86_64_LARGE = 0x10000000
enumerator SHF_HEX_GPREL = 0x10000000
enumerator SHF_MIPS_NODUPES = 0x01000000
enumerator SHF_MIPS_NAMES = 0x02000000

Linker must generate implicit hidden weak names.

enumerator SHF_MIPS_LOCAL = 0x04000000

Section data local to process.

enumerator SHF_MIPS_NOSTRIP = 0x08000000

Do not strip this section.

enumerator SHF_MIPS_GPREL = 0x10000000

Section must be part of global data area.

enumerator SHF_MIPS_MERGE = 0x20000000

This section should be merged.

enumerator SHF_MIPS_ADDR = 0x40000000

Address size to be inferred from section entry size.

enumerator SHF_MIPS_STRING = 0x80000000

Section data is string data by default.


Symbol bindings

enum class LIEF::ELF::SYMBOL_BINDINGS : size_t

Symbol bindings.

Values:

enumerator STB_LOCAL = 0

Local symbol, not visible outside obj file containing def

enumerator STB_GLOBAL = 1

Global symbol, visible to all object files being combined

enumerator STB_WEAK = 2

Weak symbol, like global but lower-precedence

enumerator STB_GNU_UNIQUE = 10
enumerator STB_LOOS = 10

Lowest operating system-specific binding type

enumerator STB_HIOS = 12

Highest operating system-specific binding type

enumerator STB_LOPROC = 13

Lowest processor-specific binding type

enumerator STB_HIPROC = 15

Highest processor-specific binding type


Symbol visibility

enum class LIEF::ELF::ELF_SYMBOL_VISIBILITY : size_t

Values:

enumerator STV_DEFAULT = 0
enumerator STV_INTERNAL = 1
enumerator STV_HIDDEN = 2
enumerator STV_PROTECTED = 3

Symbol types

enum class LIEF::ELF::ELF_SYMBOL_TYPES : size_t

Values:

enumerator STT_NOTYPE = 0
enumerator STT_OBJECT = 1
enumerator STT_FUNC = 2
enumerator STT_SECTION = 3
enumerator STT_FILE = 4
enumerator STT_COMMON = 5
enumerator STT_TLS = 6
enumerator STT_GNU_IFUNC = 10
enumerator STT_LOOS = 10
enumerator STT_HIOS = 12
enumerator STT_LOPROC = 13
enumerator STT_HIPROC = 15

Segment types

enum class LIEF::ELF::SEGMENT_TYPES : size_t

Segment types.

Values:

enumerator PT_NULL = 0

Unused segment.

enumerator PT_LOAD = 1

Loadable segment.

enumerator PT_DYNAMIC = 2

Dynamic linking information.

enumerator PT_INTERP = 3

Interpreter pathname.

enumerator PT_NOTE = 4

Auxiliary information.

enumerator PT_SHLIB = 5

Reserved.

enumerator PT_PHDR = 6

The program header table itself.

enumerator PT_TLS = 7

The thread-local storage template.

enumerator PT_LOOS = 0x60000000

Lowest operating system-specific pt entry type.

enumerator PT_HIOS = 0x6fffffff

Highest operating system-specific pt entry type.

enumerator PT_LOPROC = 0x70000000

Lowest processor-specific program hdr entry type.

enumerator PT_HIPROC = 0x7fffffff

Highest processor-specific program hdr entry type.

enumerator PT_GNU_EH_FRAME = 0x6474e550
enumerator PT_SUNW_EH_FRAME = 0x6474e550
enumerator PT_SUNW_UNWIND = 0x6464e550
enumerator PT_GNU_STACK = 0x6474e551

Indicates stack executability.

enumerator PT_GNU_PROPERTY = 0x6474e553

GNU property

enumerator PT_GNU_RELRO = 0x6474e552

Read-only after relocation.

enumerator PT_ARM_ARCHEXT = 0x70000000

Platform architecture compatibility info

enumerator PT_ARM_EXIDX = 0x70000001
enumerator PT_ARM_UNWIND = 0x70000001
enumerator PT_MIPS_REGINFO = 0x70000000

Register usage information.

enumerator PT_MIPS_RTPROC = 0x70000001

Runtime procedure table.

enumerator PT_MIPS_OPTIONS = 0x70000002

Options segment.

enumerator PT_MIPS_ABIFLAGS = 0x70000003

Abiflags segment.


Segment flags

enum class LIEF::ELF::ELF_SEGMENT_FLAGS : size_t

Segment flags.

Values:

enumerator PF_NONE = 0
enumerator PF_X = 1

Execute

enumerator PF_W = 2

Write

enumerator PF_R = 4

Read

enumerator PF_MASKOS = 0x0ff00000

Bits for operating system-specific semantics.

enumerator PF_MASKPROC = 0xf0000000

Bits for processor-specific semantics.


Dynamic tags

enum class LIEF::ELF::DYNAMIC_TAGS : size_t

Dynamic table entry tags.

Values:

enumerator DT_NULL = 0

Marks end of dynamic array.

enumerator DT_NEEDED = 1

String table offset of needed library.

enumerator DT_PLTRELSZ = 2

Size of relocation entries in PLT.

enumerator DT_PLTGOT = 3

Address associated with linkage table.

enumerator DT_HASH = 4

Address of symbolic hash table.

enumerator DT_STRTAB = 5

Address of dynamic string table.

enumerator DT_SYMTAB = 6

Address of dynamic symbol table.

enumerator DT_RELA = 7

Address of relocation table (Rela entries).

enumerator DT_RELASZ = 8

Size of Rela relocation table.

enumerator DT_RELAENT = 9

Size of a Rela relocation entry.

enumerator DT_STRSZ = 10

Total size of the string table.

enumerator DT_SYMENT = 11

Size of a symbol table entry.

enumerator DT_INIT = 12

Address of initialization function.

enumerator DT_FINI = 13

Address of termination function.

enumerator DT_SONAME = 14

String table offset of a shared objects name.

enumerator DT_RPATH = 15

String table offset of library search path.

enumerator DT_SYMBOLIC = 16

Changes symbol resolution algorithm.

enumerator DT_REL = 17

Address of relocation table (Rel entries).

enumerator DT_RELSZ = 18

Size of Rel relocation table.

enumerator DT_RELENT = 19

Size of a Rel relocation entry.

enumerator DT_PLTREL = 20

Type of relocation entry used for linking.

enumerator DT_DEBUG = 21

Reserved for debugger.

enumerator DT_TEXTREL = 22

Relocations exist for non-writable segments.

enumerator DT_JMPREL = 23

Address of relocations associated with PLT.

enumerator DT_BIND_NOW = 24

Process all relocations before execution.

enumerator DT_INIT_ARRAY = 25

Pointer to array of initialization functions.

enumerator DT_FINI_ARRAY = 26

Pointer to array of termination functions.

enumerator DT_INIT_ARRAYSZ = 27

Size of DT_INIT_ARRAY.

enumerator DT_FINI_ARRAYSZ = 28

Size of DT_FINI_ARRAY.

enumerator DT_RUNPATH = 29

String table offset of lib search path.

enumerator DT_FLAGS = 30

Flags.

enumerator DT_ENCODING = 32

Values from here to DT_LOOS follow the rules for the interpretation of the d_un union.

enumerator DT_PREINIT_ARRAY = 32

Pointer to array of preinit functions.

enumerator DT_PREINIT_ARRAYSZ = 33

Size of the DT_PREINIT_ARRAY array.

enumerator DT_SYMTAB_SHNDX = 34

Address of SYMTAB_SHNDX section

enumerator DT_RELRSZ = 35

Total size of RELR relative relocations

enumerator DT_RELR = 36

Address of RELR relative relocations

enumerator DT_RELRENT = 37

Size of one RELR relative relocaction

enumerator DT_LOOS = 0x60000000

Start of environment specific tags.

enumerator DT_HIOS = 0x6FFFFFFF

End of environment specific tags.

enumerator DT_LOPROC = 0x70000000

Start of processor specific tags.

enumerator DT_HIPROC = 0x7FFFFFFF

End of processor specific tags.

enumerator DT_GNU_HASH = 0x6FFFFEF5

Reference to the GNU hash table.

enumerator DT_RELACOUNT = 0x6FFFFFF9

ELF32_Rela count.

enumerator DT_RELCOUNT = 0x6FFFFFFA

ELF32_Rel count.

enumerator DT_FLAGS_1 = 0x6FFFFFFB

Flags_1.

enumerator DT_VERSYM = 0x6FFFFFF0

The address of .gnu.version section.

enumerator DT_VERDEF = 0x6FFFFFFC

The address of the version definition table.

enumerator DT_VERDEFNUM = 0x6FFFFFFD

The number of entries in DT_VERDEF.

enumerator DT_VERNEED = 0x6FFFFFFE

The address of the version Dependency table.

enumerator DT_VERNEEDNUM = 0x6FFFFFFF

The number of entries in DT_VERNEED.

enumerator DT_MIPS_RLD_VERSION = 0x70000001

32 bit version number for runtime linker interface.

enumerator DT_MIPS_TIME_STAMP = 0x70000002

Time stamp.

enumerator DT_MIPS_ICHECKSUM = 0x70000003

Checksum of external strings and common sizes.

enumerator DT_MIPS_IVERSION = 0x70000004

Index of version string in string table.

enumerator DT_MIPS_FLAGS = 0x70000005

32 bits of flags.

enumerator DT_MIPS_BASE_ADDRESS = 0x70000006

Base address of the segment.

enumerator DT_MIPS_MSYM = 0x70000007

Address of .msym section.

enumerator DT_MIPS_CONFLICT = 0x70000008

Address of .conflict section.

enumerator DT_MIPS_LIBLIST = 0x70000009

Address of .liblist section.

enumerator DT_MIPS_LOCAL_GOTNO = 0x7000000a

Number of local global offset table entries.

enumerator DT_MIPS_CONFLICTNO = 0x7000000b

Number of entries in the .conflict section.

enumerator DT_MIPS_LIBLISTNO = 0x70000010

Number of entries in the .liblist section.

enumerator DT_MIPS_SYMTABNO = 0x70000011

Number of entries in the .dynsym section.

enumerator DT_MIPS_UNREFEXTNO = 0x70000012

Index of first external dynamic symbol not referenced locally.

enumerator DT_MIPS_GOTSYM = 0x70000013

Index of first dynamic symbol in global offset table.

enumerator DT_MIPS_HIPAGENO = 0x70000014

Number of page table entries in global offset table.

enumerator DT_MIPS_RLD_MAP = 0x70000016

Address of run time loader map, used for debugging.

enumerator DT_MIPS_DELTA_CLASS = 0x70000017

Delta C++ class definition.

enumerator DT_MIPS_DELTA_CLASS_NO = 0x70000018

Number of entries in DT_MIPS_DELTA_CLASS.

enumerator DT_MIPS_DELTA_INSTANCE = 0x70000019

Delta C++ class instances.

enumerator DT_MIPS_DELTA_INSTANCE_NO = 0x7000001A

Number of entries in DT_MIPS_DELTA_INSTANCE.

enumerator DT_MIPS_DELTA_RELOC = 0x7000001B

Delta relocations.

enumerator DT_MIPS_DELTA_RELOC_NO = 0x7000001C

Number of entries in DT_MIPS_DELTA_RELOC.

enumerator DT_MIPS_DELTA_SYM = 0x7000001D

Delta symbols that Delta relocations refer to.

enumerator DT_MIPS_DELTA_SYM_NO = 0x7000001E

Number of entries in DT_MIPS_DELTA_SYM.

enumerator DT_MIPS_DELTA_CLASSSYM = 0x70000020

Delta symbols that hold class declarations.

enumerator DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021

Number of entries in DT_MIPS_DELTA_CLASSSYM.

enumerator DT_MIPS_CXX_FLAGS = 0x70000022

Flags indicating information about C++ flavor.

enumerator DT_MIPS_PIXIE_INIT = 0x70000023

Pixie information.

enumerator DT_MIPS_SYMBOL_LIB = 0x70000024

Address of .MIPS.symlib

enumerator DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025

The GOT index of the first PTE for a segment

enumerator DT_MIPS_LOCAL_GOTIDX = 0x70000026

The GOT index of the first PTE for a local symbol

enumerator DT_MIPS_HIDDEN_GOTIDX = 0x70000027

The GOT index of the first PTE for a hidden symbol

enumerator DT_MIPS_PROTECTED_GOTIDX = 0x70000028

The GOT index of the first PTE for a protected symbol

enumerator DT_MIPS_OPTIONS = 0x70000029

Address of .MIPS.options.

enumerator DT_MIPS_INTERFACE = 0x7000002A

Address of .interface.

enumerator DT_MIPS_DYNSTR_ALIGN = 0x7000002B

Unknown.

enumerator DT_MIPS_INTERFACE_SIZE = 0x7000002C

Size of the .interface section.

enumerator DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002D

Size of rld_text_resolve function stored in the GOT.

enumerator DT_MIPS_PERF_SUFFIX = 0x7000002E

Default suffix of DSO to be added by rld on dlopen() calls.

enumerator DT_MIPS_COMPACT_SIZE = 0x7000002F

Size of compact relocation section (O32).

enumerator DT_MIPS_GP_VALUE = 0x70000030

GP value for auxiliary GOTs.

enumerator DT_MIPS_AUX_DYNAMIC = 0x70000031

Address of auxiliary .dynamic.

enumerator DT_MIPS_PLTGOT = 0x70000032

Address of the base of the PLTGOT.

enumerator DT_MIPS_RWPLT = 0x70000034

Points to the base of a writable PLT.

enumerator DT_ANDROID_REL_OFFSET = 0x6000000D

The offset of packed relocation data (older version < M) (Android specific).

enumerator DT_ANDROID_REL_SIZE = 0x6000000E

The size of packed relocation data in bytes (older version < M) (Android specific).

enumerator DT_ANDROID_REL = 0x6000000F

The offset of packed relocation data (Android specific).

enumerator DT_ANDROID_RELSZ = 0x60000010

The size of packed relocation data in bytes (Android specific).

enumerator DT_ANDROID_RELA = 0x60000011

The offset of packed relocation data (Android specific).

enumerator DT_ANDROID_RELASZ = 0x60000012

The size of packed relocation data in bytes (Android specific).

enumerator DT_ANDROID_RELR = 0x6FFFE000

The offset of new relr relocation data (Android specific).

enumerator DT_ANDROID_RELRSZ = 0x6FFFE001

The size of nre relr relocation data in bytes (Android specific).

enumerator DT_ANDROID_RELRENT = 0x6FFFE003

The size of a new relr relocation entry (Android specific).

enumerator DT_ANDROID_RELRCOUNT = 0x6FFFE005

Specifies the relative count of new relr relocation entries (Android specific).


Dynamic flags

enum class LIEF::ELF::DYNAMIC_FLAGS : size_t

DT_FLAGS and DT_FLAGS_1 values.

Values:

enumerator DF_ORIGIN = 0x00000001

The object may reference $ORIGIN.

enumerator DF_SYMBOLIC = 0x00000002

Search the shared lib before searching the exe.

enumerator DF_TEXTREL = 0x00000004

Relocations may modify a non-writable segment.

enumerator DF_BIND_NOW = 0x00000008

Process all relocations on load.

enumerator DF_STATIC_TLS = 0x00000010

Reject attempts to load dynamically.


Dynamic flags 1

enum class LIEF::ELF::DYNAMIC_FLAGS_1 : size_t

Values:

enumerator DF_1_NOW = 0x00000001

Set RTLD_NOW for this object.

enumerator DF_1_GLOBAL = 0x00000002

Set RTLD_GLOBAL for this object.

enumerator DF_1_GROUP = 0x00000004

Set RTLD_GROUP for this object.

enumerator DF_1_NODELETE = 0x00000008

Set RTLD_NODELETE for this object.

enumerator DF_1_LOADFLTR = 0x00000010

Trigger filtee loading at runtime.

enumerator DF_1_INITFIRST = 0x00000020

Set RTLD_INITFIRST for this object.

enumerator DF_1_NOOPEN = 0x00000040

Set RTLD_NOOPEN for this object.

enumerator DF_1_ORIGIN = 0x00000080

$ORIGIN must be handled.

enumerator DF_1_DIRECT = 0x00000100

Direct binding enabled.

enumerator DF_1_TRANS = 0x00000200
enumerator DF_1_INTERPOSE = 0x00000400

Object is used to interpose.

enumerator DF_1_NODEFLIB = 0x00000800

Ignore default lib search path.

enumerator DF_1_NODUMP = 0x00001000

Object can’t be dldump’ed.

enumerator DF_1_CONFALT = 0x00002000

Configuration alternative created.

enumerator DF_1_ENDFILTEE = 0x00004000

Filtee terminates filters search.

enumerator DF_1_DISPRELDNE = 0x00008000

Disp reloc applied at build time.

enumerator DF_1_DISPRELPND = 0x00010000

Disp reloc applied at run-time.

enumerator DF_1_NODIRECT = 0x00020000

Object has no-direct binding.

enumerator DF_1_IGNMULDEF = 0x00040000
enumerator DF_1_NOKSYMS = 0x00080000
enumerator DF_1_NOHDR = 0x00100000
enumerator DF_1_EDITED = 0x00200000

Object is modified after built.

enumerator DF_1_NORELOC = 0x00400000
enumerator DF_1_SYMINTPOSE = 0x00800000

Object has individual interposers.

enumerator DF_1_GLOBAUDIT = 0x01000000

Global auditing required.

enumerator DF_1_SINGLETON = 0x02000000

Singleton symbols are used.

enumerator DF_1_PIE = 0x08000000

Singleton symbols are used.


Dynamic symbols counting

enum class LIEF::ELF::DYNSYM_COUNT_METHODS : size_t

Methods that can be used by the LIEF::ELF::Parser to count the number of dynamic symbols

Values:

enumerator COUNT_AUTO = 0

Automatic detection

enumerator COUNT_SECTION = 1

Count based on sections (not very reliable)

enumerator COUNT_HASH = 2

Count based on hash table (reliable)

enumerator COUNT_RELOCATIONS = 3

Count based on PLT/GOT relocations (very reliable but not accurate)


Relocation purpose

enum class LIEF::ELF::RELOCATION_PURPOSES : size_t

Values:

enumerator RELOC_PURPOSE_NONE = 0
enumerator RELOC_PURPOSE_PLTGOT = 1
enumerator RELOC_PURPOSE_DYNAMIC = 2
enumerator RELOC_PURPOSE_OBJECT = 3

Relocations x86-64

enum class LIEF::ELF::RELOC_x86_64 : size_t

x86_64 relocations.

Values:


Relocations x86 (i386)

enum LIEF::ELF::RELOC_i386

i386 relocations.

Values:


Relocations ARM

enum class LIEF::ELF::RELOC_ARM : size_t

Values:


Relocations AARCH64

enum class LIEF::ELF::RELOC_AARCH64 : size_t

Values:

Relocations MIPS

enum class LIEF::ELF::RELOC_MIPS : size_t

Values:

Relocations PPC

enum class LIEF::ELF::RELOC_POWERPC32 : size_t

Values:

Relocations PPC64

enum class LIEF::ELF::RELOC_POWERPC64 : size_t

Values: