x86: trampoline: fix GOT clobbering, pointed out by fabled

pull/10/head
William Pitcock 2018-02-15 04:32:16 +00:00
parent 556da6ce99
commit ef2fa49912
1 changed files with 13 additions and 2 deletions

View File

@ -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