Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 2024 08:31:58 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 53120fbb6895 - main - csu: Find the main pointer through the GOT
Message-ID:  <202405220831.44M8Vwax008767@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=53120fbb68952b7d620c2c0e1cf05c5017fc1b27

commit 53120fbb68952b7d620c2c0e1cf05c5017fc1b27
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-05-22 08:18:10 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-05-22 08:18:10 +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
---
 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405220831.44M8Vwax008767>