cortexm_common: allow defining ROM_OFFFSET in a compilation rule

Define _rom_offset with a conditional evaluated at execution time to allow
setting it in compilation rules and generate in the same make instance different
elf files with different configurations.
This commit is contained in:
Gaëtan Harter 2018-06-05 13:43:40 +02:00 committed by cladmi
parent 9103dcaeda
commit c84539fdb3
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -2,10 +2,6 @@
INCLUDES += -I$(RIOTCPU)/cortexm_common/include
INCLUDES += -I$(RIOTCPU)/cortexm_common/include/vendor
ifneq (,$(ROM_OFFSET))
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_offset=$(ROM_OFFSET)
endif
# All variables must be defined in the CPU configuration when using the common
# `ldscripts/cortexm.ld`
ifneq (,$(ROM_START_ADDR)$(RAM_START_ADDR)$(ROM_LEN)$(RAM_LEN))
@ -18,3 +14,10 @@ ifneq (,$(ROM_START_ADDR)$(RAM_START_ADDR)$(ROM_LEN)$(RAM_LEN))
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_length=$(ROM_LEN)
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_length=$(RAM_LEN)
endif
# Only define the linker symbol if the variable is set
# The variable can be set using target specific variable thanks to lazy evaluation
# ROM_OFFSET: offset in rom to start linking, allows supporting a bootloader
LINKFLAGS += $(if $(ROM_OFFSET),$(LINKFLAGPREFIX)--defsym=_rom_offset=$(ROM_OFFSET))