]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Add -X to link spec
authorFangrui Song <maskray@gcc.gnu.org>
Sat, 27 Apr 2024 01:14:33 +0000 (18:14 -0700)
committerFangrui Song <maskray@google.com>
Sat, 27 Apr 2024 01:14:33 +0000 (18:14 -0700)
--discard-locals (-X) instructs the linker to remove local .L* symbols,
which occur a lot due to label differences for linker relaxation. The
arm port has a similar need and passes -X to ld.

In contrast, the RISC-V port does not pass -X to ld and rely on the
default --discard-locals in GNU ld's riscv port. The arm way is more
conventional (compiler driver instead of the linker customizes the
default linker behavior) and works with lld.

gcc/ChangeLog:

* config/riscv/elf.h (LINK_SPEC): Add -X.
* config/riscv/freebsd.h (LINK_SPEC): Add -X.
* config/riscv/linux.h (LINK_SPEC): Add -X.

gcc/config/riscv/elf.h
gcc/config/riscv/freebsd.h
gcc/config/riscv/linux.h

index f533764d9f86d720d60e24f41c55dbe7a2ecf24c..c97f13c0ccad0bbd70cd1cdaeb72a2d0a28e6b17 100644 (file)
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
 -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv \
 %{mno-relax:--no-relax} \
+-X \
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{shared}"
index bd08a985285039a2ec9be48cef90c07c7e17caf1..5dd4d51c42bc719af9e11b8b91a844cb82680ba9 100644 (file)
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
   %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}   \
   %{v:-V}                                                      \
   %{assert*} %{R*} %{rpath*} %{defsym*}                                \
+  -X                                                           \
   %{mbig-endian:-EB}                                           \
   %{mlittle-endian:-EL}                                                \
   %{shared:-Bshareable %{h*} %{soname*}}                       \
index 15851f653bc621c6aab3f1d4ec1a0e2a1771fead..3c356227134d7bf576b3a2332c8f366f080fb99e 100644 (file)
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
 -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
 %{mno-relax:--no-relax} \
+-X \
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{shared} \