mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
Kernel+Userland: Make the stack alignment comply with the System V ABI
The System V ABI for both x86 and x86_64 requires that the stack pointer is 16-byte aligned on entry. Previously we did not align the stack pointer properly. As far as "main" was concerned the stack alignment was correct even without this patch due to how the C++ _start function and the kernel interacted, i.e. the kernel misaligned the stack as far as the ABI was concerned but that misalignment (read: it was properly aligned for a regular function call - but misaligned in terms of what the ABI dictates) was actually expected by our _start function.
This commit is contained in:
parent
f4a318ee2d
commit
06883ed8a3
8 changed files with 69 additions and 17 deletions
|
@ -94,9 +94,15 @@ this helper program directly.
|
|||
extern "C" {
|
||||
|
||||
// The compiler expects a previous declaration
|
||||
void _start(int, char**, char**);
|
||||
void _entry(int, char**, char**);
|
||||
|
||||
void _start(int argc, char** argv, char** envp)
|
||||
asm(
|
||||
".globl _start\n"
|
||||
"_start:\n"
|
||||
"push $0\n"
|
||||
"jmp _entry@plt\n");
|
||||
|
||||
void _entry(int argc, char** argv, char** envp)
|
||||
{
|
||||
char** env;
|
||||
for (env = envp; *env; ++env) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue