riscv: linker: fix PMP support on non-XIP system.

On non-XIP system, RAM region overlaps ROM region which cause PMP region
overlapping. Padding RAM region by adding a output section to update
the next free address of RAM region.

Signed-off-by: Jim Shu <cwshu@andestech.com>
This commit is contained in:
Jim Shu 2021-09-01 17:32:53 +08:00 committed by Christopher Friedt
commit 8d8d6d9a6a

View file

@ -187,7 +187,6 @@ SECTIONS
#include <linker/cplusplus-rom.ld>
__rodata_region_end = .;
MPU_ALIGN(__rodata_region_end - __rom_region_start);
/* For non-XIP system, __rom_region_end symbol should be set to
* the end of common ROMABLE_REGIONs (text and rodata) instead of
@ -195,6 +194,13 @@ SECTIONS
* RAMABLE_REGION in it.
*/
#ifndef CONFIG_XIP
#ifdef CONFIG_RISCV_PMP
SECTION_PROLOGUE(rom_mpu_padding,,)
{
MPU_ALIGN(__rodata_region_end - __rom_region_start);
} GROUP_LINK_IN(ROMABLE_REGION)
#endif /* CONFIG_RISCV_PMP */
__rom_region_end = .;
__rom_region_size = __rom_region_end - __rom_region_start;
#endif /* CONFIG_XIP */