mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
UserspaceEmulator: Improve the initial program stack a tiny bit
Instead of starting with argv=nullptr, envp=nullptr, programs now start with both pointing to a null terminated array (that immediately terminates.) :^)
This commit is contained in:
parent
fa98dcc05d
commit
463afa69a7
1 changed files with 14 additions and 4 deletions
|
@ -105,10 +105,20 @@ void Emulator::setup_stack()
|
|||
m_mmu.add_region(move(stack_region));
|
||||
m_cpu.set_esp(stack_location + stack_size);
|
||||
|
||||
m_cpu.push32(0);
|
||||
m_cpu.push32(0);
|
||||
m_cpu.push32(0);
|
||||
m_cpu.push32(0);
|
||||
m_cpu.push32(0); // char** envp = { nullptr }
|
||||
u32 envp = m_cpu.esp();
|
||||
|
||||
m_cpu.push32(0); // char** argv = { nullptr }
|
||||
u32 argv = m_cpu.esp();
|
||||
|
||||
m_cpu.push32(0); // (alignment)
|
||||
m_cpu.push32(0); // (alignment)
|
||||
|
||||
u32 argc = 0;
|
||||
m_cpu.push32(envp);
|
||||
m_cpu.push32(argv);
|
||||
m_cpu.push32(argc);
|
||||
m_cpu.push32(0); // (alignment)
|
||||
}
|
||||
|
||||
bool Emulator::load_elf()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue