Skip to main content

bootstrap_stack

Function bootstrap_stack 

Source
pub fn bootstrap_stack(
    stack_mem: &mut [u8],
    stack_guest_base: u64,
    argv: &[&str],
    envp: &[&str],
) -> Result<u64, StackError>
Expand description

Builds a minimal C-like stack image at the high end of stack_mem.

Layout (low → high addresses toward sp growing down):

  [strings: argv bytes, env bytes]
  [padding to 16-byte align]
  argc
  argv[0..n]
  NULL
  envp[0..m]
  NULL
  NULL   // empty Apple/aux terminator

Returns the guest stack pointer (16-byte aligned) that should be loaded into sp before jumping to the entry point.