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 60d01d779ff05805acbb73074467f3262f70b8d7
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Sep 27 10:04:10 2026 +0200

    arch/arm: Reach an NXFLAT module's read-only data through the GOT.
    
    A module's D-Space is separate from its I-Space, so its read-only data is 
not
    at a fixed offset from its text.  GCC assumes that it is and loads a string
    literal PC-relative, which reads I-Space at run time.  A module could
    therefore carry no string and reach no static.
    
    lm3s6965-ek has had -mno-pic-data-is-text-relative in its own Make.defs 
since
    2021 (issue #3737), and the CMake build gives it to every PIC configuration,
    so the flag moves to where it belonged and the board's copy goes.  That copy
    also probed for GCC older than 4.9.4, which NuttX no longer supports.  Clang
    has no such option, hence the guard.
    
    Assisted-by: Claude Opus 5 (1M context) <[email protected]>
    Signed-off-by: Marco Casaroli <[email protected]>
---
 arch/arm/src/common/Toolchain.defs            | 10 ++++++++++
 boards/arm/tiva/lm3s6965-ek/scripts/Make.defs | 12 ------------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/arch/arm/src/common/Toolchain.defs 
b/arch/arm/src/common/Toolchain.defs
index c169e2d25ec..43f3e1c6932 100644
--- a/arch/arm/src/common/Toolchain.defs
+++ b/arch/arm/src/common/Toolchain.defs
@@ -585,6 +585,16 @@ ARCHPICFLAGS ?= -fpic -msingle-pic-base -mpic-register=r9
 # out of CONFIG_ARM_THUMB rather than having to say anything.
 
 ifeq ($(CONFIG_NXFLAT),y)
+  # A module's D-Space is separate from its I-Space, so its read-only data is
+  # not at a fixed offset from its text.  gnu-nxflat-gotoff.ld reaches that
+  # data through the GOT; this makes the compiler do the same.  lm3s6965-ek
+  # carried the flag in its own Make.defs, and the CMake build gives it to
+  # every PIC configuration.  See issue #3737.  Clang has no such option.
+
+  ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),)
+    ARCHPICFLAGS += -mno-pic-data-is-text-relative
+  endif
+
   ifeq ($(CONFIG_ARM_THUMB),y)
     MKNXFLAT ?= $(TOPDIR)$(DELIM)tools$(DELIM)mknxflat$(HOSTEXEEXT) -a thumb2
   else
diff --git a/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs 
b/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs
index db4d113b53e..fa62068fa19 100644
--- a/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs
+++ b/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs
@@ -33,18 +33,6 @@ else
   ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script
 endif
 
-ifeq ($(CONFIG_NXFLAT),y)
-  # mpic-data-is-text-relative flag first time appeared in GCC source code 
tree on 2016-Jul-12
-  # and it was included in GCC 4.9.4 release on 2016-Aug-03.
-  ARCHCC_HAS_PIC_DATA_IS_TEXT_RELATIVE_FLAG = ${shell $(CC) --target-help 2>&1 
| grep -c "mpic-data-is-text-relative"}
-
-  # Turn off -mpic-data-is-text-relative flag to access bss via the GOT
-  # 
(https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139630111)
-  ifneq ($(ARCHCC_HAS_PIC_DATA_IS_TEXT_RELATIVE_FLAG),0)
-    ARCHPICFLAGS += -mno-pic-data-is-text-relative
-  endif
-endif
-
 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) 
$(ARCHDEFINES) $(EXTRAFLAGS)
 CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) 
$(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
 CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)

Reply via email to