From 131a5dfd626dbe181daace46400820f57b97d810 Mon Sep 17 00:00:00 2001 From: Immo Birnbaum Date: Fri, 10 Dec 2021 15:28:42 +0100 Subject: [PATCH] arch: arm: aarch32: fix section alignment behind rodata region start marker Fix for issue 39978. This commit assigns the __rodata_region_start marker to the ROMABLE region prior to the inclusion of linker/common-rom.ld, linker/thread-local-storage.ld and linker/cplusplus-rom.ld. Prior to this fix, the __rodata_region_start marker was properly aligned and indicated the expected memory location for the start of the rodata section and similar sections, but it was disconnected from the ROMABLE region into which the subsequent sections are being integrated, resulting in placement of those sections right behind the previous section in the ROMABLE region and therefore at addresses below the __rodata_region_start marker. For the sake of consistent behaviour, the end marker of the text region has been modified accordingly. Signed-off-by: Immo Birnbaum --- .../arch/arm/aarch32/cortex_a_r/scripts/linker.ld | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 e7069a1bb87..1fb054a48c9 100644 --- a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld @@ -62,7 +62,7 @@ _region_min_align = CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE; #elif defined(CONFIG_ARM_AARCH32_MMU) _region_min_align = CONFIG_MMU_PAGE_SIZE; #else -/* If building without MPU support, use default 4-byte alignment. */ +/* If building without MPU/MMU support, use default 4-byte alignment. */ _region_min_align = 4; #endif @@ -151,11 +151,10 @@ SECTIONS */ *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + __text_region_end = .; + . = ALIGN(_region_min_align); } GROUP_LINK_IN(ROMABLE_REGION) - __text_region_end = .; - . = ALIGN(_region_min_align); - #if defined (CONFIG_CPLUSPLUS) SECTION_PROLOGUE(.ARM.extab,,) { @@ -181,8 +180,11 @@ SECTIONS __exidx_end = .; } GROUP_LINK_IN(ROMABLE_REGION) - . = ALIGN(_region_min_align); - __rodata_region_start = .; + SECTION_PROLOGUE(rodata_start,,) + { + . = ALIGN(_region_min_align); + __rodata_region_start = .; + } GROUP_LINK_IN(ROMABLE_REGION) #include #include