diff --git a/src/system/glue/arch/x86_64/crti.S b/src/system/glue/arch/x86_64/crti.S index 3ef8e5f8df..ec26b6d5a3 100644 --- a/src/system/glue/arch/x86_64/crti.S +++ b/src/system/glue/arch/x86_64/crti.S @@ -30,6 +30,7 @@ FUNCTION(_init): // Preserve image ID for call to __haiku_init_after. push %rdi + sub $0x8, %rsp call __haiku_init_before // crtbegin.o stuff comes here @@ -39,5 +40,6 @@ FUNCTION(_fini): push %rbp movq %rsp, %rbp push %rdi + sub $0x8, %rsp call __haiku_term_before // crtend.o stuff comes here diff --git a/src/system/glue/arch/x86_64/crtn.S b/src/system/glue/arch/x86_64/crtn.S index 8ed6433843..6eb07e181a 100644 --- a/src/system/glue/arch/x86_64/crtn.S +++ b/src/system/glue/arch/x86_64/crtn.S @@ -13,6 +13,7 @@ .section .init // The image ID is preserved on the stack. + add $0x8, %rsp pop %rdi call __haiku_init_after movq %rbp, %rsp @@ -20,6 +21,7 @@ ret .section .fini + add $0x8, %rsp pop %rdi call __haiku_term_after movq %rbp, %rsp