From dee8ef6f4f1cf90b8a57dd6c6c8cdb6bbd65791f Mon Sep 17 00:00:00 2001 From: David Brown Date: Mon, 12 Dec 2016 11:44:50 -0700 Subject: [PATCH] arm: cortex-m: Implement CONFIG_TEXT_SECTION_OFFSET On other targets, CONFIG_TEXT_SECTION_OFFSET allows the entire image to be moved in memory to allow space for some type of header. The Mynewt project bootloader prepends a small header, and this config needs to be supported for this to work. The specific alignment requirements of the vector table are chip specific, and generally will be a power of two larger than the size of the vector table. Change-Id: I631a42ff64fb8ab86bd177659f2eac5208527653 Signed-off-by: David Brown --- arch/arm/core/cortex_m/prep_c.c | 3 ++- include/arch/arm/cortex_m/scripts/linker.ld | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/core/cortex_m/prep_c.c b/arch/arm/core/cortex_m/prep_c.c index 9bbbf76545e..a8c918ba5de 100644 --- a/arch/arm/core/cortex_m/prep_c.c +++ b/arch/arm/core/cortex_m/prep_c.c @@ -29,7 +29,8 @@ static inline void relocate_vector_table(void) { /* do nothing */ } static inline void relocate_vector_table(void) { /* vector table is located at the the beginning of the flash */ - _scs_relocate_vector_table((void *)CONFIG_FLASH_BASE_ADDRESS); + _scs_relocate_vector_table((void *)(CONFIG_FLASH_BASE_ADDRESS + + CONFIG_TEXT_SECTION_OFFSET)); } #else static inline void relocate_vector_table(void) diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index 781a92ea217..f97a8534a6e 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -72,6 +72,7 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { + . = CONFIG_TEXT_SECTION_OFFSET; KEEP(*(.exc_vector_table)) KEEP(*(".exc_vector_table.*"))