From fa2cf3500725c6d8f37705f736deaa0034f18e89 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 22 Dec 2025 16:51:46 +1100 Subject: [PATCH] feat(ld_so/x86_64): do not use the `call` trick Signed-off-by: Anhad Singh --- ld_so/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ld_so/src/lib.rs b/ld_so/src/lib.rs index b4c54565e3..44800b06e3 100644 --- a/ld_so/src/lib.rs +++ b/ld_so/src/lib.rs @@ -70,17 +70,14 @@ global_asm!( " .globl _start _start: - # rsi = _start + 5 - call 2f -2: pop rsi + lea rsi, [rip + _start] # Save original stack and align stack to 16 bytes mov rbp, rsp - and rsp, 0xFFFFFFFFFFFFFFF0 + and rsp, 0xfffffffffffffff0 - # Call ld_so_start(stack, entry) + # Call ld_so_start(stack=rdi, ld_entry=rsi) mov rdi, rbp - sub rsi, 5 call relibc_ld_so_start # Restore original stack, clear registers, and jump to new start function @@ -95,6 +92,7 @@ _start: xor r11, r11 fninit jmp rax + ud2 " );