pub fn get_app_stack_region(
    args: Vec<String>,
    envs: &[String],
    auxv: BTreeMap<u8, usize>,
    stack_top: VirtAddr,
    stack_size: usize
) -> (Vec<u8>, usize)
Expand description

To get the app stack and the information on the stack from the ELF file

Arguments

  • args - The arguments of the app
  • envs - The environment variables of the app
  • auxv - The auxv vector of the app
  • stack_top - The top address of the stack
  • stack_size - The size of the stack.

Return

(stack_content, real_stack_bottom)

  • stack_content: the stack data from the low address to the high address, which will be used to map in the memory

  • real_stack_bottom: The initial stack bottom is stack_top + stack_size.After push arguments into the stack, it will return the real stack bottom

The return data will be divided into two parts.

  • The first part is the free stack content, which is all 0.
  • The second part is the content carried by the user stack when it is initialized, such as args, auxv, etc.

The detailed format is described in https://articles.manugarg.com/aboutelfauxiliaryvectors.html