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

Abstract base class for Linux-specific executable loading and setup routines. More...

#include <lnx_loader.hpp>

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

Public Member Functions

virtual std::unique_ptr< LNX_LOADER_PARAMSprocess ()=0
 

Protected Member Functions

 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)
 
virtual void setup_specific_auxv (std::shared_ptr< LNX_LOADER_PARAMS > params, uint16_t arch_sz)=0
 
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)
 

Protected Attributes

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.
 

Private Member Functions

void setup_auxv (std::unique_ptr< AUXV_PTRS > auxv_ptrs, std::shared_ptr< LNX_LOADER_PARAMS > params)
 
void setup_envp (std::vector< ADDR > envp_ptrs)
 
void setup_argv (std::vector< ADDR > argv_ptrs)
 

Detailed Description

Abstract base class for Linux-specific executable loading and setup routines.

Constructor & Destructor Documentation

◆ LinuxLoader()

arion::LinuxLoader::LinuxLoader ( std::weak_ptr< Arion arion,
const std::vector< std::string >  program_args,
const std::vector< std::string >  program_env 
)
inlineprotected

Builder for LinuxLoader instances.

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

Member Function Documentation

◆ init_main_thread()

void arion::LinuxLoader::init_main_thread ( std::shared_ptr< LNX_LOADER_PARAMS params,
ADDR  entry_addr 
)
protected

Initializes the main thread's registers (e.g., PC, stack pointer) for execution to begin.

Parameters
[in]paramsShared pointer to the loader parameters structure.
[in]entry_addrThe initial entry point address (usually the program or interpreter entry point).

◆ map_stack()

ADDR arion::LinuxLoader::map_stack ( std::shared_ptr< LNX_LOADER_PARAMS params,
std::string  path 
)
protected

Maps the initial process stack into memory and writes the argument/environment strings onto it.

Parameters
[in]paramsShared pointer to the loader parameters structure.
[in]pathThe path to the executable file.
Returns
The base address of the mapped stack.

◆ process()

virtual std::unique_ptr< LNX_LOADER_PARAMS > arion::LinuxLoader::process ( )
pure virtual

**(Pure Virtual)** Main loading routine for the process (to be implemented by derived classes).

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

Implemented in arion::ElfLoader, and arion::LinuxBaremetalLoader.

◆ setup_argv()

void arion::LinuxLoader::setup_argv ( std::vector< ADDR argv_ptrs)
private

Writes the argument pointers (argv) to the stack.

Parameters
[in]argv_ptrsVector of memory addresses pointing to the argument strings.

◆ setup_auxv()

void arion::LinuxLoader::setup_auxv ( std::unique_ptr< AUXV_PTRS auxv_ptrs,
std::shared_ptr< LNX_LOADER_PARAMS params 
)
private

Completes the setup of the Auxiliary Vector, writing key addresses and values to the stack.

Parameters
[in]auxv_ptrsUnique pointer to the structure holding temporary addresses for string placement.
[in]paramsShared pointer to the structure holding loaded addresses.

◆ setup_envp()

void arion::LinuxLoader::setup_envp ( std::vector< ADDR envp_ptrs)
private

Writes the environment variable pointers to the stack.

Parameters
[in]envp_ptrsVector of memory addresses pointing to the environment strings.

◆ setup_specific_auxv()

virtual void arion::LinuxLoader::setup_specific_auxv ( std::shared_ptr< LNX_LOADER_PARAMS params,
uint16_t  arch_sz 
)
protectedpure virtual

**(Pure Virtual)** Sets up architecture-specific AUXV entries (to be implemented by derived classes).

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

Implemented in arion::ElfLoader, and arion::LinuxBaremetalLoader.

◆ write_auxv_entry()

void arion::LinuxLoader::write_auxv_entry ( AUXV  auxv,
uint64_t  val 
)
protected

Writes a single entry (key-value pair) to the Auxiliary Vector on the stack.

Parameters
[in]auxvThe AUXV key.
[in]valThe corresponding value to store.

Member Data Documentation

◆ arion

std::weak_ptr<Arion> arion::LinuxLoader::arion
protected

Weak pointer back to the main Arion instance.

◆ program_args

const std::vector<std::string> arion::LinuxLoader::program_args
protected

Vector of command-line arguments.

◆ program_env

const std::vector<std::string> arion::LinuxLoader::program_env
protected

Vector of environment variables.


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