Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
arion::ElfLoader Class Reference

A Linux loader implementation responsible for parsing and mapping ELF binaries (executables and dynamic loaders). More...

#include <elf_loader.hpp>

Inheritance diagram for arion::ElfLoader:
arion::LinuxLoader

Public Member Functions

 ElfLoader (std::weak_ptr< Arion > arion, std::shared_ptr< ElfParser > interp_parser, std::shared_ptr< ElfParser > prog_parser, const std::vector< std::string > program_args, const std::vector< std::string > program_env)
 
 ElfLoader (std::weak_ptr< Arion > arion, std::shared_ptr< ElfParser > prog_parser, const std::vector< std::string > program_args, const std::vector< std::string > program_env)
 
std::unique_ptr< LNX_LOADER_PARAMSprocess () override
 

Protected Member Functions

void setup_specific_auxv (std::shared_ptr< LNX_LOADER_PARAMS > params, uint16_t arch_sz) override
 

Private Member Functions

ADDR map_elf_segments (const std::shared_ptr< ElfParser > parser, ADDR load_addr)
 
ADDR map_vvar ()
 
ADDR map_vdso ()
 
ADDR map_vsyscall ()
 
ADDR map_arm_traps ()
 
void init_coredump_threads ()
 
 LinuxLoader (std::weak_ptr< Arion > arion, const std::vector< std::string > program_args, const std::vector< std::string > program_env)
 
void write_auxv_entry (AUXV auxv, uint64_t val)
 
ADDR map_stack (std::shared_ptr< LNX_LOADER_PARAMS > params, std::string path)
 
void init_main_thread (std::shared_ptr< LNX_LOADER_PARAMS > params, ADDR entry_addr)
 

Private Attributes

std::shared_ptr< ElfParserprog_parser
 ELF parser for the program interpreter (dynamic linker).
 
std::shared_ptr< ElfParserinterp_parser
 
bool is_pie
 Flag indicating if the program is Position-Independent Executable (PIE).
 
bool is_static
 Flag indicating if the program is statically linked.
 
- Private Attributes inherited from arion::LinuxLoader
std::weak_ptr< Arionarion
 Weak pointer back to the main Arion instance.
 
const std::vector< std::string > program_args
 Vector of command-line arguments.
 
const std::vector< std::string > program_env
 Vector of environment variables.
 

Detailed Description

A Linux loader implementation responsible for parsing and mapping ELF binaries (executables and dynamic loaders).

Constructor & Destructor Documentation

◆ ElfLoader() [1/2]

arion::ElfLoader::ElfLoader ( std::weak_ptr< Arion arion,
std::shared_ptr< ElfParser interp_parser,
std::shared_ptr< ElfParser prog_parser,
const std::vector< std::string >  program_args,
const std::vector< std::string >  program_env 
)
inline

Builder for a dynamically linked ElfLoader instance.

Parameters
[in]arionWeak pointer to the Arion emulator instance.
[in]interp_parserELF parser for the dynamic linker.
[in]prog_parserELF parser for the main program.
[in]program_argsVector of command-line arguments.
[in]program_envVector of environment variables.

◆ ElfLoader() [2/2]

arion::ElfLoader::ElfLoader ( std::weak_ptr< Arion arion,
std::shared_ptr< ElfParser prog_parser,
const std::vector< std::string >  program_args,
const std::vector< std::string >  program_env 
)
inline

Builder for a statically linked ElfLoader instance.

Parameters
[in]arionWeak pointer to the Arion emulator instance.
[in]prog_parserELF parser for the main program.
[in]program_argsVector of command-line arguments.
[in]program_envVector of environment variables.

Member Function Documentation

◆ init_coredump_threads()

void arion::ElfLoader::init_coredump_threads ( )
private

Initializes thread synchronization structures related to coredumps.

◆ map_arm_traps()

ADDR arion::ElfLoader::map_arm_traps ( )
private

Maps the 32-bit ARM kernel trap page into memory.

Returns
The base virtual address of the ARM traps page.

◆ map_elf_segments()

ADDR arion::ElfLoader::map_elf_segments ( const std::shared_ptr< ElfParser parser,
ADDR  load_addr 
)
private

Maps the loadable segments of an ELF binary into the emulator's memory space.

Parameters
[in]parserThe ELF parser instance.
[in]load_addrThe base virtual address to load the segments at.
Returns
The actual base address where the ELF segments were loaded.

◆ map_vdso()

ADDR arion::ElfLoader::map_vdso ( )
private

Maps the kernel's Virtual Dynamic Shared Object (VDSO) page into memory.

Returns
The base virtual address of the VDSO page.

◆ map_vsyscall()

ADDR arion::ElfLoader::map_vsyscall ( )
private

Maps the kernel's Virtual Syscall (VSYSCALL) page into memory.

Returns
The base virtual address of the VSYSCALL page.

◆ map_vvar()

ADDR arion::ElfLoader::map_vvar ( )
private

Maps the kernel's Virtual Variable (VVAR) page into memory.

Returns
The base virtual address of the VVAR page.

◆ process()

std::unique_ptr< LNX_LOADER_PARAMS > arion::ElfLoader::process ( )
overridevirtual

Processes the ELF binary loading, mapping segments, setting up the stack, and finalizing the loader parameters.

Returns
A unique pointer to the finalized loader parameters (LNX_LOADER_PARAMS).

Implements arion::LinuxLoader.

◆ setup_specific_auxv()

void arion::ElfLoader::setup_specific_auxv ( std::shared_ptr< LNX_LOADER_PARAMS params,
uint16_t  arch_sz 
)
overrideprotectedvirtual

Sets up architecture-specific Auxiliary Vector (AUXV) entries before execution starts.

Parameters
[in]paramsShared pointer to the loader parameters structure.
[in]arch_szThe size of the architecture (32 or 64 bit).

Implements arion::LinuxLoader.

Member Data Documentation

◆ interp_parser

std::shared_ptr<ElfParser> arion::ElfLoader::interp_parser
private

◆ is_pie

bool arion::ElfLoader::is_pie
private

Flag indicating if the program is Position-Independent Executable (PIE).

◆ is_static

bool arion::ElfLoader::is_static
private

Flag indicating if the program is statically linked.

◆ prog_parser

std::shared_ptr<ElfParser> arion::ElfLoader::prog_parser
private

ELF parser for the program interpreter (dynamic linker).


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