From 6adeec09e94079bb6e0c6d9ffc01ef9da5c863ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Wed, 9 May 2018 07:52:32 +0200 Subject: [PATCH] atmega_common: add arch specific XFA ldscript to properly place .roxfa --- cpu/atmega_common/ldscripts/xfa.ld | 16 ++++++++++++++++ makefiles/arch/atmega.inc.mk | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 cpu/atmega_common/ldscripts/xfa.ld diff --git a/cpu/atmega_common/ldscripts/xfa.ld b/cpu/atmega_common/ldscripts/xfa.ld new file mode 100644 index 0000000000..29b85699c9 --- /dev/null +++ b/cpu/atmega_common/ldscripts/xfa.ld @@ -0,0 +1,16 @@ +SECTIONS +{ + .data : + { + /* Special case for AVR (Harvard architecture) where .rodata is merged + * into .data by the toolchain default ldscripts. */ + KEEP (*(SORT(.roxfa.*))) + KEEP (*(SORT(.xfa.*))) + } + __data_start = ADDR(.data); + __data_load_start = LOADADDR(.data); + __data_end = (__data_start + SIZEOF(.data)); + __data_load_end = (__data_load_start + SIZEOF(.data)); +} + +INSERT AFTER .text; diff --git a/makefiles/arch/atmega.inc.mk b/makefiles/arch/atmega.inc.mk index 2c2169323d..98c7d83c25 100644 --- a/makefiles/arch/atmega.inc.mk +++ b/makefiles/arch/atmega.inc.mk @@ -9,8 +9,11 @@ CFLAGS_OPT ?= -Os CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) + +# needed for xfa support. Order is important. +LINKFLAGS += -T$(RIOTCPU)/atmega_common/ldscripts/xfa.ld + LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections -OFLAGS += -j .text -j .data # Use ROM_LEN and RAM_LEN during link $(if $(ROM_LEN),,$(error ROM_LEN is not defined))