1
Fork 0
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:
Andreas Kling 2020-07-11 21:28:09 +02:00
parent fa98dcc05d
commit 463afa69a7

View file

@ -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()