https://gcc.gnu.org/g:8e6cc1e7cdbb431a0950e491ed2830213f3ad81b
commit r15-4707-g8e6cc1e7cdbb431a0950e491ed2830213f3ad81b Author: Fangrui Song <mask...@gcc.gnu.org> Date: Sun Oct 27 12:37:21 2024 -0700 arm: Support -mfdpic for more targets Targets that are not arm*-*-uclinuxfdpiceabi can use -S -mfdpic, but -c -mfdpic does not pass --fdpic to gas. This is an unnecessary restriction. Just define the ASM_SPEC in bpabi.h. Additionally, use armelf[b]_linux_fdpiceabi emulations for -mfdpic in linux-eabi.h. This will allow a future musl fdpic port to use the desired BFD emulation. gcc/ChangeLog: * config/arm/bpabi.h (TARGET_FDPIC_ASM_SPEC): Transform -mfdpic. * config/arm/linux-eabi.h (TARGET_FDPIC_LINKER_EMULATION): Define. (SUBTARGET_EXTRA_LINK_SPEC): Use TARGET_FDPIC_LINKER_EMULATION if -mfdpic. Diff: --- gcc/config/arm/bpabi.h | 2 +- gcc/config/arm/linux-eabi.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h index 2e418fa91350..fd4b65a28afe 100644 --- a/gcc/config/arm/bpabi.h +++ b/gcc/config/arm/bpabi.h @@ -55,7 +55,7 @@ #define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}" -#define TARGET_FDPIC_ASM_SPEC "" +#define TARGET_FDPIC_ASM_SPEC "%{mfdpic: --fdpic}" #define BE8_LINK_SPEC \ "%{!r:%{!mbe32:%:be8_linkopt(%{mlittle-endian:little}" \ diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h index 50b753df9bcd..b12e4ff82cc3 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -46,12 +46,15 @@ #undef TARGET_LINKER_EMULATION #if TARGET_BIG_ENDIAN_DEFAULT #define TARGET_LINKER_EMULATION "armelfb_linux_eabi" +#define TARGET_FDPIC_LINKER_EMULATION "armelfb_linux_fdpiceabi" #else #define TARGET_LINKER_EMULATION "armelf_linux_eabi" +#define TARGET_FDPIC_LINKER_EMULATION "armelf_linux_fdpiceabi" #endif #undef SUBTARGET_EXTRA_LINK_SPEC -#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION +#define SUBTARGET_EXTRA_LINK_SPEC " -m %{mfdpic: " \ + TARGET_FDPIC_LINKER_EMULATION ";:" TARGET_LINKER_EMULATION "}" /* GNU/Linux on ARM currently supports three dynamic linkers: - ld-linux.so.2 - for the legacy ABI