LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
LIEF::ELF::Parser Class Reference

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

#include <Parser.hpp>

Inheritance diagram for LIEF::ELF::Parser:
Collaboration diagram for LIEF::ELF::Parser:

Public Types

enum  ELF_TYPE { ELF_UNKNOWN , ELF32 , ELF64 }

Public Member Functions

Parseroperator= (const Parser &)=delete
 Parser (const Parser &)=delete
 ~Parser () override

Static Public Member Functions

static std::unique_ptr< Binaryparse (const std::string &file, const ParserConfig &conf=ParserConfig::all())
 Parse an ELF file and return a LIEF::ELF::Binary object.
static std::unique_ptr< Binaryparse (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.
static std::unique_ptr< Binaryparse (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.
static std::unique_ptr< Binaryparse_from_memory (uintptr_t address, const ParserConfig &conf=ParserConfig::all())
 Parse the ELF binary from the given memory address.
static std::unique_ptr< Binaryparse_from_memory (uintptr_t address, size_t size, const ParserConfig &conf=ParserConfig::all())
 Parse the ELF binary from the given memory address with the given size.
static std::unique_ptr< Binaryparse_from_dump (const std::string &filepath, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
 Parse an ELF binary from a memory dump located on disk.
static std::unique_ptr< Binaryparse_from_dump (BinaryStream &stream, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
 Same as parse_from_dump(const std::string&, uint64_t, const ParserConfig&) but the dump is wrapped in the given non-owned stream.
static std::unique_ptr< Binaryparse_from_dump (std::unique_ptr< BinaryStream > stream, uint64_t addr, const ParserConfig &conf=ParserConfig::all())
 Same as parse_from_dump(const std::string&, uint64_t, const ParserConfig&) but the dump is wrapped in the given owned stream.
Static Public Member Functions inherited from LIEF::Parser
static std::unique_ptr< Binaryparse (const std::string &filename)
 Construct an LIEF::Binary from the given filename.
static std::unique_ptr< Binaryparse (const std::vector< uint8_t > &raw)
 Construct an LIEF::Binary from the given raw data.
static std::unique_ptr< Binaryparse (std::unique_ptr< BinaryStream > stream)
 Construct an LIEF::Binary from the given stream.

Static Public 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 MAX_SEGMENT_SIZE = 3_GB

Detailed Description

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

Member Enumeration Documentation

◆ ELF_TYPE

Enumerator
ELF_UNKNOWN 
ELF32 
ELF64 

Constructor & Destructor Documentation

◆ Parser()

LIEF::ELF::Parser::Parser ( const Parser & )
delete

References OAT::Parser.

◆ ~Parser()

LIEF::ELF::Parser::~Parser ( )
overridevirtual

Reimplemented from LIEF::Parser.

References LIEF_LOCAL, and OAT::Parser.

Member Function Documentation

◆ operator=()

Parser & LIEF::ELF::Parser::operator= ( const Parser & )
delete

References OAT::Parser.

◆ parse() [1/3]

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

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
[in]filePath to the ELF binary
[in]confOptional configuration for the parser
Returns
LIEF::ELF::Binary as a unique_ptr

References LIEF::ELF::ParserConfig::all().

◆ parse() [2/3]

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

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 to use to count dynamic symbols

Parameters
[in]dataRaw ELF as a std::vector of uint8_t
[in]confOptional configuration for the parser
Returns
LIEF::ELF::Binary

References LIEF::ELF::ParserConfig::all().

◆ parse() [3/3]

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

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 to use to count dynamic symbols

Parameters
[in]streamThe stream which wraps the ELF binary
[in]confOptional configuration for the parser
Returns
LIEF::ELF::Binary

References LIEF::ELF::ParserConfig::all().

◆ parse_from_dump() [1/3]

std::unique_ptr< Binary > LIEF::ELF::Parser::parse_from_dump ( BinaryStream & stream,
uint64_t addr,
const ParserConfig & conf = ParserConfig::all() )
static

Same as parse_from_dump(const std::string&, uint64_t, const ParserConfig&) but the dump is wrapped in the given non-owned stream.

References LIEF::ELF::ParserConfig::all().

◆ parse_from_dump() [2/3]

std::unique_ptr< Binary > LIEF::ELF::Parser::parse_from_dump ( const std::string & filepath,
uint64_t addr,
const ParserConfig & conf = ParserConfig::all() )
static

Parse an ELF binary from a memory dump located on disk.

A dump is a raw capture of the process memory that was mapped starting at the virtual address addr. This is typically used to parse an ELF image that has been dumped from memory (e.g. from a debugger or a runtime hook).

Parameters
[in]filepathPath to the file that contains the memory dump
[in]addrVirtual address at which the dump was mapped
[in]confOptional configuration for the parser

References LIEF::ELF::ParserConfig::all().

◆ parse_from_dump() [3/3]

std::unique_ptr< Binary > LIEF::ELF::Parser::parse_from_dump ( std::unique_ptr< BinaryStream > stream,
uint64_t addr,
const ParserConfig & conf = ParserConfig::all() )
static

Same as parse_from_dump(const std::string&, uint64_t, const ParserConfig&) but the dump is wrapped in the given owned stream.

References LIEF::ELF::ParserConfig::all().

◆ parse_from_memory() [1/2]

std::unique_ptr< Binary > LIEF::ELF::Parser::parse_from_memory ( uintptr_t address,
const ParserConfig & conf = ParserConfig::all() )
static

Parse the ELF binary from the given memory address.

Parameters
[in]addressBase address of the ELF binary in memory
[in]confOptional configuration for the parser
Returns
LIEF::ELF::Binary

References LIEF::ELF::ParserConfig::all().

◆ parse_from_memory() [2/2]

std::unique_ptr< Binary > LIEF::ELF::Parser::parse_from_memory ( uintptr_t address,
size_t size,
const ParserConfig & conf = ParserConfig::all() )
static

Parse the ELF binary from the given memory address with the given size.

Parameters
[in]addressBase address of the ELF binary in memory
[in]sizeSize of the memory region
[in]confOptional configuration for the parser
Returns
LIEF::ELF::Binary

References LIEF::ELF::ParserConfig::all().

Member Data Documentation

◆ DELTA_NB_SYMBOLS

uint32_t LIEF::ELF::Parser::DELTA_NB_SYMBOLS = 3000
staticconstexpr

◆ MAX_SEGMENT_SIZE

uint32_t LIEF::ELF::Parser::MAX_SEGMENT_SIZE = 3_GB
staticconstexpr

◆ NB_MAX_BUCKETS

uint32_t LIEF::ELF::Parser::NB_MAX_BUCKETS = NB_MAX_SYMBOLS
staticconstexpr

◆ NB_MAX_CHAINS

uint32_t LIEF::ELF::Parser::NB_MAX_CHAINS = 1000000
staticconstexpr

◆ NB_MAX_DYNAMIC_ENTRIES

uint32_t LIEF::ELF::Parser::NB_MAX_DYNAMIC_ENTRIES = 1000
staticconstexpr

◆ NB_MAX_RELOCATIONS

uint32_t LIEF::ELF::Parser::NB_MAX_RELOCATIONS = 3000000
staticconstexpr

◆ NB_MAX_SEGMENTS

uint32_t LIEF::ELF::Parser::NB_MAX_SEGMENTS = 10000
staticconstexpr

◆ NB_MAX_SYMBOLS

uint32_t LIEF::ELF::Parser::NB_MAX_SYMBOLS = 1000000
staticconstexpr

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