public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: libc-alpha@sourceware.org
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	caiyinyu <caiyinyu@loongson.cn>, WANG Xuerui <i@xen0n.name>,
	Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH 2/3] LoongArch: Remove support code for old linker in start.S
Date: Sun, 27 Aug 2023 00:36:50 +0800	[thread overview]
Message-ID: <20230826163651.35828-3-xry111@xry111.site> (raw)
In-Reply-To: <20230826163651.35828-1-xry111@xry111.site>

We are requiring Binutils >= 2.41, so la.pcrel always works here.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
 sysdeps/loongarch/start.S | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/sysdeps/loongarch/start.S b/sysdeps/loongarch/start.S
index e9d82033b7..bf6bfc9ea4 100644
--- a/sysdeps/loongarch/start.S
+++ b/sysdeps/loongarch/start.S
@@ -60,20 +60,7 @@ ENTRY (ENTRY_POINT)
 	cfi_undefined (1)
 	or		a5, a0, zero /* rtld_fini */
 
-#if ENABLE_STATIC_PIE
-/* For static PIE, the GOT cannot be used in _start because the GOT entries are
-   offsets instead of real addresses before __libc_start_main.
-   __libc_start_main and/or main may be not local, so we rely on the linker to
-   produce PLT entries for them.  GNU ld >= 2.40 supports this.  */
-# define LA la.pcrel
-#else
-/* Old GNU ld (< 2.40) cannot handle PC relative address against a non-local
-   function correctly.  We deem these old linkers failing to support static PIE
-   and load the addresses from GOT.  */
-# define LA la.got
-#endif
-
-	LA		a0, t0, main
+	la.pcrel	a0, t0, main
 	REG_L		a1, sp, 0
 	ADDI		a2, sp, SZREG
 
@@ -84,9 +71,9 @@ ENTRY (ENTRY_POINT)
 	move		a4, zero /* used to be fini */
 	or		a6, sp, zero /* stack_end */
 
-	LA		ra, t0, __libc_start_main
+	la.pcrel	ra, t0, __libc_start_main
 	jirl		ra, ra, 0
 
-	LA		ra, t0, abort
+	la.pcrel	ra, t0, abort
 	jirl		ra, ra, 0
 END (ENTRY_POINT)
-- 
2.42.0


  parent reply	other threads:[~2023-08-26 16:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26 16:36 [PATCH 0/3] LoongArch: Clean up after Binutils minimal version bump Xi Ruoyao
2023-08-26 16:36 ` [PATCH 1/3] LoongArch: Simplify the autoconf check for static PIE Xi Ruoyao
2023-08-26 16:36 ` Xi Ruoyao [this message]
2023-08-26 16:36 ` [PATCH 3/3] LoongArch: Micro-optimize LD_PCREL Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230826163651.35828-3-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=i@xen0n.name \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).