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 */