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)