From 3dbd2d7492c7a3b574354a91d550a06f71f7b748 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Mon, 23 Mar 2020 17:08:08 +0200 Subject: [PATCH] plat/*: Use PIC in thread_start.S Use RIP-relative addressing for position independent code (PIC). Signed-off-by: Razvan Deaconescu Reviewed-by: Simon Kuenzer --- plat/common/x86/thread_start.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plat/common/x86/thread_start.S b/plat/common/x86/thread_start.S index b23666ae2..360ca910c 100644 --- a/plat/common/x86/thread_start.S +++ b/plat/common/x86/thread_start.S @@ -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 -- 2.39.5