]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/*: Use PIC in thread_start.S
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 23 Mar 2020 15:08:08 +0000 (17:08 +0200)
committerSimon Kuenzer <simon.kuenzer@neclab.eu>
Wed, 4 Nov 2020 11:33:39 +0000 (12:33 +0100)
Use RIP-relative addressing for position independent code (PIC).

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
plat/common/x86/thread_start.S

index b23666ae227fdd874bac89445cbc5e16236d1bcb..360ca910c26a051b22d89002290f492a947d43a1 100644 (file)
@@ -36,7 +36,7 @@ ENTRY(asm_thread_starter)
        pushq $0
        xorq %rbp,%rbp
        call *%rbx
-       call uk_sched_thread_exit
+       call *uk_sched_thread_exit@GOTPCREL(%rip)
 
 ENTRY(asm_ctx_start)
        mov %rdi, %rsp      /* set SP */
@@ -52,10 +52,11 @@ ENTRY(asm_sw_ctx_switch)
        pushq %r15
        movq %rsp, OFFSETOF_SW_CTX_SP(%rdi)       /* save ESP */
        movq OFFSETOF_SW_CTX_SP(%rsi), %rsp       /* restore ESP */
-       movq $1f, OFFSETOF_SW_CTX_IP(%rdi)        /* save EIP */
+       lea .Lreturn(%rip), %rbx
+       movq %rbx, OFFSETOF_SW_CTX_IP(%rdi)       /* save EIP */
        pushq OFFSETOF_SW_CTX_IP(%rsi)            /* restore EIP */
        ret
-1:
+.Lreturn:
        popq %r15
        popq %r14
        popq %r13