diff --git a/arch/x86/startcontext.S b/arch/x86/startcontext.S index 2bb87ee..3304863 100644 --- a/arch/x86/startcontext.S +++ b/arch/x86/startcontext.S @@ -15,15 +15,26 @@ __start_context: /* get the proper context into position and test for NULL */ leal (%esp,%ebx,4), %esp cmpl $0, (%esp) - je hosed + + /* restore global offset table, exit@plt and __setcontext@plt need this */ + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + + /* if we have no linked context, lets get out of here */ + je no_linked_context /* call setcontext to switch to the linked context */ call __setcontext@plt movl %eax, (%esp) -hosed: +no_linked_context: /* we are returning into a null context, it seems, so maybe we should exit */ call exit@plt /* something is really hosed, call hlt to force termination */ hlt + + +__i686.get_pc_thunk.bx: + mov (%esp), %ebx + ret