Skip to content

Commit

Permalink
build sytem: add --no-warn-rwx-segments to linker
Browse files Browse the repository at this point in the history
Before we disabled the warning about RWX segments only for picolibc,
but this issue is popping up on more and more toolchains (looking
at MSP430 and RISC-V). Other than on `native`/`native64`, there is no
MMU to enforce whatever permissions the segments contain anyway.
(And writing to ROM with regular store instructions will not be possible
even without the need for an MMU.)

So let's just globally disable this warning, unless building for
`native` and `native64`.
  • Loading branch information
maribu committed Feb 12, 2024
1 parent f68f977 commit c9f16f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@ TOOLCHAINS_SUPPORTED ?= gnu
# Import all toolchain settings
include $(RIOTMAKE)/toolchain/$(TOOLCHAIN).inc.mk

# Other than on native, RWX segments in ROM are not actually RWX, as regular
# store instructions won't write to flash.
ifeq (,$(filter native native64,$(BOARD)))
LINKER_SUPPORTS_NOWARNRWX ?= $(shell LC_ALL=C $(LINK) $(RIOTTOOLS)/testprogs/minimal_linkable.c -o /dev/null -lc -Wall -Wextra -pedantic -Wl,--no-warn-rwx-segments 2> /dev/null && echo 1 || echo 0)
ifeq (1,$(LINKER_SUPPORTS_NOWARNRWX))
LINKFLAGS += -Wl,--no-warn-rwx-segments
endif
endif

# Append ldscript path after importing CPU and board makefiles to allow
# overriding the core ldscripts
LINKFLAGS += -L$(RIOTBASE)/core/ldscripts
Expand Down
8 changes: 0 additions & 8 deletions makefiles/libc/picolibc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ ifeq (1,$(USE_PICOLIBC))
CFLAGS += -DPICOLIBC_INTEGER_PRINTF_SCANF
LINKFLAGS += -DPICOLIBC_INTEGER_PRINTF_SCANF
endif
# For some reason segments with RWX permissions will be created with
# picolibc. But since (as of now) RIOT only supports disabling the execute of
# all RAM via the `mpu_noexec_ram` module, permissions of the segments are
# ignored anyway. So for now, we just simply disable the warning.
LINKER_SUPPORTS_NOWARNRWX ?= $(shell LC_ALL=C $(LINK) $(RIOTTOOLS)/testprogs/minimal_linkable.c -o /dev/null -lc -Wall -Wextra -pedantic -Wl,--no-warn-rwx-segments 2> /dev/null && echo 1 || echo 0)
ifeq (1,$(LINKER_SUPPORTS_NOWARNRWX))
LINKFLAGS += -Wl,--no-warn-rwx-segments
endif
endif

LINKFLAGS += -lc

0 comments on commit c9f16f1

Please sign in to comment.