diff --git a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld index fd67ed4fe63..907eac34816 100644 --- a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld @@ -108,7 +108,11 @@ SECTIONS GROUP_START(ROMABLE_REGION) +#if defined(CONFIG_XIP) _image_rom_start = ROM_ADDR; +#else + _image_rom_start = RAM_ADDR; +#endif SECTION_PROLOGUE(rom_start,,) { @@ -175,6 +179,7 @@ SECTIONS #include #include +#include SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) { @@ -200,13 +205,17 @@ SECTIONS * usually 4k aligned. */ . = ALIGN(4); + + /* + * RODATA must be the last section so that the size of the entire read + * only area will be filled to a power of 2. + */ + MPU_ALIGN(ABSOLUTE(.) - _image_rom_start); } GROUP_LINK_IN(ROMABLE_REGION) -#include - _image_rodata_end = .; - MPU_ALIGN(_image_rodata_end -_image_rom_start); _image_rom_end = .; + _image_rom_end_order = (LOG2CEIL(_image_rom_end) - 1) << 1; GROUP_END(ROMABLE_REGION)