riscv: linker: fix __rom_region_end in non-XIP system
In non-XIP system, because ROMABLE_REGION == RAMABLE_REGION, setting __rom_region_size/end symbol at linker script end will mistakely contain RAMABLE_REGION in it. Move __rom_region_end symbol to end of common ROMABLE_REGION (text and rodata) instead in non-XIP system. Signed-off-by: Jim Shu <cwshu@andestech.com>
This commit is contained in:
parent
4a35785240
commit
c1dc4a6f61
1 changed files with 16 additions and 0 deletions
|
@ -188,6 +188,16 @@ 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
|
||||
* the linker script end, so it wouldn't mistakely contain
|
||||
* RAMABLE_REGION in it.
|
||||
*/
|
||||
#ifndef CONFIG_XIP
|
||||
__rom_region_end = .;
|
||||
__rom_region_size = __rom_region_end - __rom_region_start;
|
||||
#endif /* CONFIG_XIP */
|
||||
GROUP_END(ROMABLE_REGION)
|
||||
|
||||
GROUP_START(RAMABLE_REGION)
|
||||
|
@ -361,6 +371,11 @@ GROUP_END(DTCM)
|
|||
KEEP(*(.gnu.attributes))
|
||||
}
|
||||
|
||||
/* 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 mistakely contain the RAMABLE_REGION in it.
|
||||
*/
|
||||
#ifdef CONFIG_XIP
|
||||
/* Must be last in romable region */
|
||||
SECTION_PROLOGUE(.last_section,(NOLOAD),)
|
||||
{
|
||||
|
@ -370,5 +385,6 @@ SECTION_PROLOGUE(.last_section,(NOLOAD),)
|
|||
* calculate this value here. */
|
||||
__rom_region_end = LOADADDR(.last_section);
|
||||
__rom_region_size = __rom_region_end - __rom_region_start;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue