git: 71f04a360965 - stable/14 - csu: Find the main pointer through the GOT
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 Jul 2024 12:38:20 UTC
The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=71f04a3609655a1b9cfb28d45e2f5bf41dcb4e67 commit 71f04a3609655a1b9cfb28d45e2f5bf41dcb4e67 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2024-05-22 08:18:10 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2024-07-15 12:26:22 +0000 csu: Find the main pointer through the GOT Use the Global Offset Table to find the location of main in crt1. With lld the old code would point to main@plt, however ld.bfd fails to link when main is in a shared library. Fix this by using the GOT address to find main as it works with both lld and bfd. Reviewed by: jrtc27 Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45259 (cherry picked from commit 53120fbb68952b7d620c2c0e1cf05c5017fc1b27) --- lib/csu/aarch64/crt1_s.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/csu/aarch64/crt1_s.S b/lib/csu/aarch64/crt1_s.S index 981cf4653efd..1fb60f756a7a 100644 --- a/lib/csu/aarch64/crt1_s.S +++ b/lib/csu/aarch64/crt1_s.S @@ -44,8 +44,8 @@ ENTRY(_start) add x2, x1, x0, lsl #3 /* env is after argv */ add x2, x2, #8 /* argv is null terminated */ #ifdef PIC - adrp x4, main - add x4, x4, :lo12:main + adrp x4, :got:main + ldr x4, [x4, :got_lo12:main] #else ldr x4, =main #endif