mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Kernel: Make processes start with a 16-byte-aligned stack
This commit is contained in:
parent
cf7df418ed
commit
bd563f0b3c
Notes:
sideshowbarker
2024-07-18 18:48:18 +09:00
Author: https://github.com/ccapitalK Commit: https://github.com/SerenityOS/serenity/commit/bd563f0b3c0 Pull-request: https://github.com/SerenityOS/serenity/pull/6789 Issue: https://github.com/SerenityOS/serenity/issues/6785 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/tomuta
1 changed files with 6 additions and 0 deletions
|
@ -131,12 +131,18 @@ static KResultOr<FlatPtr> make_userspace_stack_for_main_thread(Region& region, V
|
|||
|
||||
// NOTE: The stack needs to be 16-byte aligned.
|
||||
new_esp -= new_esp % 16;
|
||||
// GCC assumes that the return address has been pushed to the stack when it enters the function,
|
||||
// so we need to reserve an extra pointer's worth of bytes below this to make GCC's stack alignment
|
||||
// calculations work
|
||||
new_esp -= sizeof(void*);
|
||||
|
||||
push_on_new_stack((FlatPtr)envp);
|
||||
push_on_new_stack((FlatPtr)argv);
|
||||
push_on_new_stack((FlatPtr)argv_entries.size());
|
||||
push_on_new_stack(0);
|
||||
|
||||
VERIFY((new_esp + sizeof(void*)) % 16 == 0);
|
||||
|
||||
return new_esp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue