From 362501a097cfc77fc6e4d577b84117d816fa22f3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 9 Nov 2025 16:31:59 +0200 Subject: [PATCH] LibC: Make x86_64 crt0 PIE compatible Instead of pushing addresses of functions directly, use rip relative addressing --- userspace/libraries/LibC/arch/x86_64/crt0.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/userspace/libraries/LibC/arch/x86_64/crt0.S b/userspace/libraries/LibC/arch/x86_64/crt0.S index 75627909..d4d9a609 100644 --- a/userspace/libraries/LibC/arch/x86_64/crt0.S +++ b/userspace/libraries/LibC/arch/x86_64/crt0.S @@ -19,13 +19,13 @@ _start: movq %rdx, %rdi # environ - pushq $__fini_array_end - pushq $__fini_array_start - pushq $_fini + leaq __fini_array_end(%rip), %rax; pushq %rax + leaq __fini_array_start(%rip), %rax; pushq %rax + leaq _fini(%rip), %rax; pushq %rax - pushq $__init_array_end - pushq $__init_array_start - pushq $_init + leaq __init_array_end(%rip), %rax; pushq %rax + leaq __init_array_start(%rip), %rax; pushq %rax + leaq _init(%rip), %rax; pushq %rax call _init_libc