[PATCH 3/3] LoongArch: Enable shared library and PIE support for loongarch*-elf

mintsuki mintsuki@protonmail.com
Thu Sep 3 17:52:53 GMT 2026


loongarch*-elf withholds GENERATE_SHLIB_SCRIPT and GENERATE_PIE_SCRIPT,
so ld refuses -shared and -pie for it.  The exclusion arrived with the
original LoongArch ld port, copied from the RISC-V emulparams, and no
reason was recorded for it either.  loongarch*-elf does not set
EMBEDDED.

The rationale is the one given for the RISC-V patch in this series; it
applies here unchanged.

ld/
	* emulparams/elf32loongarch-defs.sh (GENERATE_SHLIB_SCRIPT): Set
	unconditionally rather than only for non-loongarch*-elf targets.
	(GENERATE_PIE_SCRIPT): Likewise.
	* emulparams/elf64loongarch-defs.sh (GENERATE_SHLIB_SCRIPT):
	Likewise.
	(GENERATE_PIE_SCRIPT): Likewise.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Mintsuki <mintsuki@protonmail.com>
---
 ld/emulparams/elf32loongarch-defs.sh | 11 ++---------
 ld/emulparams/elf64loongarch-defs.sh | 11 ++---------
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/ld/emulparams/elf32loongarch-defs.sh b/ld/emulparams/elf32loongarch-defs.sh
index f80f5742..05626db0 100644
--- a/ld/emulparams/elf32loongarch-defs.sh
+++ b/ld/emulparams/elf32loongarch-defs.sh
@@ -16,15 +16,8 @@ if test `echo "$host" | sed -e s/64//` = `echo "$target" | sed -e s/64//`; then
   esac
 fi
 
-# Enable shared library support for everything except an embedded elf target.
-case "$target" in
-  loongarch*-elf)
-    ;;
-  *)
-    GENERATE_SHLIB_SCRIPT=yes
-    GENERATE_PIE_SCRIPT=yes
-    ;;
-esac
+GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
 
 IREL_IN_PLT=
 TEXT_START_ADDR=0x10000
diff --git a/ld/emulparams/elf64loongarch-defs.sh b/ld/emulparams/elf64loongarch-defs.sh
index a8147bf7..9b9deabb 100644
--- a/ld/emulparams/elf64loongarch-defs.sh
+++ b/ld/emulparams/elf64loongarch-defs.sh
@@ -16,15 +16,8 @@ if test `echo "$host" | sed -e s/64//` = `echo "$target" | sed -e s/64//`; then
   esac
 fi
 
-# Enable shared library support for everything except an embedded elf target.
-case "$target" in
-  loongarch*-elf)
-    ;;
-  *)
-    GENERATE_SHLIB_SCRIPT=yes
-    GENERATE_PIE_SCRIPT=yes
-    ;;
-esac
+GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
 
 # In all cases, the number is big-endian.
 # LoongArch nop is 'andi $r0,$r0,0'.
-- 
2.55.0




More information about the Binutils mailing list