From 8d8d6d9a6a088777fdac0cc33d0045decf081556 Mon Sep 17 00:00:00 2001 From: Jim Shu Date: Wed, 1 Sep 2021 17:32:53 +0800 Subject: [PATCH] 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 --- include/arch/riscv/common/linker.ld | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index baed73aa628..d032c6e442d 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -187,7 +187,6 @@ SECTIONS #include __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 */