1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/msp430_common: Fix linking with binutils 2.40

An `INSERT AFTER` directive no longer can refer to a different linker
script included with `-T path/to/script.ld`. Instead, this adds wrapper
linker scripts that just `INCLUDE` the three individual linker scripts.
This way, the xfa.ld can safely refer back to sections defined in
the vendor linker script.

For some reason, this approach cause the exact issue it fixes for
binutils 2.40 with the binutils in the CI. We stick with the old
linker flags with binutils prior 2.40 to be compatible with both
conflicting behaviors.

The best approach would be to come up with something that works across
different versions of binutils; but no such solution materialized.
This commit is contained in:
Marian Buschsieweke 2023-04-19 17:46:17 +02:00
parent 812c216f0c
commit b123f1071a
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94
5 changed files with 26 additions and 4 deletions

View File

@ -0,0 +1,3 @@
INCLUDE msp430f1611.ld
INCLUDE msp430_common.ld
INCLUDE xfa.ld

View File

@ -0,0 +1,3 @@
INCLUDE msp430f1612.ld
INCLUDE msp430_common.ld
INCLUDE xfa.ld

View File

@ -0,0 +1,3 @@
INCLUDE msp430f1617.ld
INCLUDE msp430_common.ld
INCLUDE xfa.ld

View File

@ -0,0 +1,3 @@
INCLUDE msp430f2617.ld
INCLUDE msp430_common.ld
INCLUDE xfa.ld

View File

@ -13,11 +13,21 @@ CFLAGS_OPT ?= -Os
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
ASFLAGS += $(CFLAGS_CPU) --defsym $(CPU_MODEL)=1 $(CFLAGS_DBG)
BINUTILS_VERSION := $(shell $(PREFIX)ld --version | grep -Eo '[0-9]\.[0-9]+')
NEEDS_NEW_LINKER_SCRIPT := $(call version_is_greater_or_equal,$(BINUTILS_VERSION),2.40)
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT)
LINKFLAGS += -Wl,--gc-sections -Wl,-L$(MSP430_SUPPORT_FILES)/include
LINKFLAGS += -T $(MSP430_SUPPORT_FILES)/include/$(CPU_MODEL).ld
LINKFLAGS += -T $(RIOTCPU)/msp430_common/ldscripts/msp430_common.ld
LINKFLAGS += $(RIOTCPU)/msp430_common/ldscripts/xfa.ld
LINKFLAGS += -Wl,--gc-sections
LINKFLAGS += -Wl,-L$(MSP430_SUPPORT_FILES)/include
LINKFLAGS += -Wl,-L$(RIOTCPU)/msp430_common/ldscripts
ifeq (1,$(NEEDS_NEW_LINKER_SCRIPT))
LINKFLAGS += -T riot-$(CPU_MODEL).ld
else
LINKFLAGS += -T $(MSP430_SUPPORT_FILES)/include/$(CPU_MODEL).ld
LINKFLAGS += -T $(RIOTCPU)/msp430_common/ldscripts/msp430_common.ld
LINKFLAGS += $(RIOTCPU)/msp430_common/ldscripts/xfa.ld
endif
OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow