This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 00e51b847ab3e9414335c418d04b2324bbfa47e8
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 6 22:55:17 2026 +0200

    arch/arm: Pass --fdpic to the assembler for an FDPIC module.
    
    GCC before 14 does not pass --fdpic to the assembler when it compiles
    with -mfdpic.  The assembler then rejects every FDPIC relocation with
    "Relocation supported only in FDPIC mode".  The NuttX CI image has GCC
    13.2, so the crt0.o of an FDPIC configuration does not build there.
    
    Pass -Wa,--fdpic with -mfdpic, in the make build and the CMake build.  A
    newer GCC passes the same option itself.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 arch/arm/src/cmake/elf.cmake       |  7 +++++--
 arch/arm/src/common/Toolchain.defs | 11 +++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/arm/src/cmake/elf.cmake b/arch/arm/src/cmake/elf.cmake
index 2a0b3f61ccb..465f442ae3f 100644
--- a/arch/arm/src/cmake/elf.cmake
+++ b/arch/arm/src/cmake/elf.cmake
@@ -56,14 +56,17 @@ if(CONFIG_FDPIC)
       "${FDPIC_LD}"
       CACHE INTERNAL "Linker for FDPIC modules")
 
-  nuttx_elf_compile_options(-mfdpic -fPIC -Wa,--noexecstack)
+  # GCC before 14 does not pass --fdpic to the assembler for -mfdpic, and the
+  # assembler then rejects the FDPIC relocations, so pass it here.
+
+  nuttx_elf_compile_options(-mfdpic -fPIC -Wa,--noexecstack -Wa,--fdpic)
 
   nuttx_elf_link_options(-m armelf_linux_fdpiceabi -shared -z now)
 
   # A shared library is an FDPIC shared object too, as LDMODULEFLAGS makes it 
in
   # common/Toolchain.defs
 
-  nuttx_mod_compile_options(-mfdpic -fPIC -Wa,--noexecstack)
+  nuttx_mod_compile_options(-mfdpic -fPIC -Wa,--noexecstack -Wa,--fdpic)
 
   nuttx_mod_link_options(-m armelf_linux_fdpiceabi -shared -z now)
 
diff --git a/arch/arm/src/common/Toolchain.defs 
b/arch/arm/src/common/Toolchain.defs
index 6325df91cb7..d681cd17278 100644
--- a/arch/arm/src/common/Toolchain.defs
+++ b/arch/arm/src/common/Toolchain.defs
@@ -684,8 +684,11 @@ ifeq ($(CONFIG_FDPIC),y)
     MODULELD = $(SHELL) -c 'echo "ERROR: $(FDPIC_NO_LD_MSG)" 1>&2; exit 1' --
   endif
 
-  CELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack
-  CXXELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack
+  # GCC before 14 does not pass --fdpic to the assembler for -mfdpic, and the
+  # assembler then rejects the FDPIC relocations, so pass it here.
+
+  CELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack -Wa,--fdpic
+  CXXELFFLAGS += -mfdpic -fPIC -Wa,--noexecstack -Wa,--fdpic
 
   LDELFFLAGS += -m armelf_linux_fdpiceabi -shared -z now
 
@@ -697,8 +700,8 @@ ifeq ($(CONFIG_FDPIC),y)
   # The entry point is left to the caller:  a module is entered at _start,
   # a library is only called into.
 
-  CMODULEFLAGS += -mfdpic -fPIC -Wa,--noexecstack
-  CXXMODULEFLAGS += -mfdpic -fPIC -Wa,--noexecstack
+  CMODULEFLAGS += -mfdpic -fPIC -Wa,--noexecstack -Wa,--fdpic
+  CXXMODULEFLAGS += -mfdpic -fPIC -Wa,--noexecstack -Wa,--fdpic
 
   LDMODULEFLAGS = -m armelf_linux_fdpiceabi -shared -z now \
                   -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)

Reply via email to