Skip to content

Commit d8bdddd

Browse files
danieldegrassecarlescufi
authored andcommitted
arch: arm: aarch32: introduce CONFIG_BUILD_ALIGN_LMA
Introduce CONFIG_BUILD_ALIGN_LMA. When enabled, this symbol will add a padding section after the final read only data section in the image. This padding section will ensure that the LMA of the data sections follows the same alignment restrictions as the VMA does. This LMA alignment is needed for objcopy to adjust the LMA address of the output ELF file. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent c255130 commit d8bdddd

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Kconfig.zephyr

+9
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,15 @@ config BUILD_OUTPUT_INFO_HEADER
674674
- VMA address of each segment
675675
- Size of each segment
676676

677+
config BUILD_ALIGN_LMA
678+
bool "Align LMA in output image"
679+
default y if BUILD_OUTPUT_ADJUST_LMA!=""
680+
help
681+
Ensure that the LMA for each section in the output image respects
682+
the alignment requirements of that section. This is required for
683+
some tooling, such as objcopy, to be able to adjust the LMA of the
684+
ELF file.
685+
677686
config APPLICATION_DEFINED_SYSCALL
678687
bool "Scan application folder for any syscall definition"
679688
help

include/zephyr/arch/arm/aarch32/cortex_m/scripts/linker.ld

+13
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,21 @@ SECTIONS
206206

207207
#include <zephyr/linker/cplusplus-rom.ld>
208208

209+
#if defined(CONFIG_BUILD_ALIGN_LMA)
210+
/*
211+
* Include a padding section here to make sure that the LMA address
212+
* of the sections in the RAMABLE_REGION are aligned with those
213+
* section's VMA alignment requirements.
214+
*/
215+
SECTION_PROLOGUE(padding_section,,)
216+
{
217+
__rodata_region_end = .;
218+
MPU_ALIGN(__rodata_region_end - ADDR(rom_start));
219+
} GROUP_LINK_IN(ROMABLE_REGION)
220+
#else
209221
__rodata_region_end = .;
210222
MPU_ALIGN(__rodata_region_end - ADDR(rom_start));
223+
#endif
211224
__rom_region_end = __rom_region_start + . - ADDR(rom_start);
212225

213226
GROUP_END(ROMABLE_REGION)

0 commit comments

Comments
 (0)