mirror of
https://github.com/apache/nuttx.git
synced 2026-10-02 11:48:02 +00:00
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) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
40783f8343
commit
60d01d779f
2 changed files with 10 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue