soc: andestech: linker.ld: clarify usage of __rom_region_end/size
Clarify usage of __rom_region_end/size in XIP system. When PMP is enabled, __rom_region_end should be padded to meet the requirement of PMP entry, and the actual ROM region usage ends at .last_section instead of __rom_region_end. Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
This commit is contained in:
parent
ed021551dc
commit
f80377bd4e
1 changed files with 12 additions and 6 deletions
|
@ -400,10 +400,6 @@ GROUP_END(DTCM)
|
||||||
/* Sections generated from 'zephyr,memory-region' nodes */
|
/* Sections generated from 'zephyr,memory-region' nodes */
|
||||||
LINKER_DT_SECTIONS()
|
LINKER_DT_SECTIONS()
|
||||||
|
|
||||||
/* Because ROMABLE_REGION != RAMABLE_REGION in XIP-system, it is valid
|
|
||||||
* to set __rom_region_end symbol at the end of linker script and
|
|
||||||
* doesn't mistakenly contain the RAMABLE_REGION in it.
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_XIP
|
#ifdef CONFIG_XIP
|
||||||
/* Must be last in romable region */
|
/* Must be last in romable region */
|
||||||
SECTION_PROLOGUE(.last_section,,)
|
SECTION_PROLOGUE(.last_section,,)
|
||||||
|
@ -415,17 +411,27 @@ SECTION_PROLOGUE(.last_section,,)
|
||||||
#endif
|
#endif
|
||||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
|
|
||||||
|
/* Because ROMABLE_REGION != RAMABLE_REGION in XIP-system, it is valid
|
||||||
|
* to set __rom_region_end symbol at the end of linker script and
|
||||||
|
* doesn't mistakenly contain the RAMABLE_REGION in it.
|
||||||
|
*/
|
||||||
#ifndef CONFIG_RISCV_PMP
|
#ifndef CONFIG_RISCV_PMP
|
||||||
/* To provide the image size as a const expression,
|
|
||||||
* calculate this value here. */
|
|
||||||
__rom_region_end = LOADADDR(.last_section) + SIZEOF(.last_section);
|
__rom_region_end = LOADADDR(.last_section) + SIZEOF(.last_section);
|
||||||
#else
|
#else
|
||||||
|
/* Padding __rom_region_end to matches the requirement of the MPU region.
|
||||||
|
* __rom_region_size is used to configure the MPU region, but the actual rom
|
||||||
|
* region data usage is ends at .last_section.
|
||||||
|
*/
|
||||||
SECTION_PROLOGUE(rom_mpu_padding,(NOLOAD),)
|
SECTION_PROLOGUE(rom_mpu_padding,(NOLOAD),)
|
||||||
{
|
{
|
||||||
MPU_ALIGN(__rom_region_size);
|
MPU_ALIGN(__rom_region_size);
|
||||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
__rom_region_end = LOADADDR(rom_mpu_padding) + SIZEOF(rom_mpu_padding);
|
__rom_region_end = LOADADDR(rom_mpu_padding) + SIZEOF(rom_mpu_padding);
|
||||||
#endif /* !CONFIG_RISCV_PMP */
|
#endif /* !CONFIG_RISCV_PMP */
|
||||||
|
|
||||||
|
/* To provide the rom region size as a const expression,
|
||||||
|
* calculate this value here.
|
||||||
|
*/
|
||||||
__rom_region_size = __rom_region_end - __rom_region_start;
|
__rom_region_size = __rom_region_end - __rom_region_start;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue