diff --git a/src/system/runtime_loader/arch/x86/arch_call_init_term.c b/src/system/runtime_loader/arch/x86/arch_call_init_term.c index e0844804d2..e92fcf6a08 100644 --- a/src/system/runtime_loader/arch/x86/arch_call_init_term.c +++ b/src/system/runtime_loader/arch/x86/arch_call_init_term.c @@ -17,13 +17,21 @@ arch_call_init(image_t *image) // This calls the init code in crti.S (in glue/arch/x86/) // It would have been too easy to just call this function with its arguments // on the stack, so Be went the ugly way. Once more. - asm("mov %0, %%ebx; call *%1" : : "g"(image->id), "g"(image->init_routine)); + asm("push %%ebx;" + "mov %0, %%ebx;" + "call *%1;" + "pop %%ebx" + : : "g"(image->id), "g"(image->init_routine)); } void arch_call_term(image_t *image) { - asm("mov %0, %%ebx; call *%1" : : "g"(image->id), "g"(image->term_routine)); + asm("push %%ebx;" + "mov %0, %%ebx;" + "call *%1;" + "pop %%ebx" + : : "g"(image->id), "g"(image->term_routine)); }