From fe81c51dcdd4c24316da632d4eb4d0bf7ab6bc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 27 May 2019 15:42:22 +0200 Subject: [PATCH] tests/cortexm_common_ldscript: update code section for kinetis Update the 'code' section detection to also work on kinetis. The boards using 'cortexm.ld' have the code section starting with '.text'. For the 'cpu/kinetis/kinetis.ls' the first section is '.vector'. Update the 'awk' matching pattern to correctly detect the kinetis boards. It is a dependency to allow testing upcoming offset support with kinetis. I am not 100% sure about the pattern for awk. --- tests/cortexm_common_ldscript/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/cortexm_common_ldscript/Makefile b/tests/cortexm_common_ldscript/Makefile index d04e375c71..178c50b615 100644 --- a/tests/cortexm_common_ldscript/Makefile +++ b/tests/cortexm_common_ldscript/Makefile @@ -86,10 +86,15 @@ OFFSETS_TESTS = 0x1000 0x2000 tests-offsets: $(OFFSETS_TESTS:%=test-offset_%) .PHONY: test-offset_% +# Match the 'code' section. It is usually '.text' but is '.vector' on `kinetis`. +# * [ 1] .text PROGBITS 08001000 001000 001ef8 ... +# * [ 1] .vector PROGBITS 00001000 001000 000400 ... +# So match with the section [ 1] being `PROGBITS`. Adapt if new cases appear. +CODE_SECTION = \[ 1\] \.[a-zA-Z_.]* *PROGBITS test-offset_%: $(BINDIR)/$(APPLICATION)_offset_%.elf $(Q)echo -n "Test compilation with offset $*: " $(Q)\ - TEST_START_ADDR=$$($(PREFIX)readelf --section-headers $^ 2>/dev/null | awk '/.text/{printf "0x%s\n", $$5}'); \ + TEST_START_ADDR=$$($(PREFIX)readelf --section-headers $^ 2>/dev/null | awk '/$(CODE_SECTION)/{printf "0x%s\n", $$5}'); \ EXPECT_START_ADDR=$$(printf "0x%08x" $$(( $(ROM_START_ADDR) + $* ))); \ if test $${TEST_START_ADDR} != $${EXPECT_START_ADDR}; then \ echo "[ERROR] Linker offset not used $${TEST_START_ADDR} != $${EXPECT_START_ADDR}" >&2; \