Skip to content

Commit 8c9c43f

Browse files
committed
[nrf noup] soc: riscv: Add end of relocation address to start of the code
In order to allow extract relocation code size from the binary add dummy instruction at the beginning which will write address of the end of the relocation part to the register. It is decoded by the host core which copies riscv code. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 06d1dd7 commit 8c9c43f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/zephyr/arch/riscv/common/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ SECTIONS
343343
* zephyr_linker_sources() Cmake function.
344344
*/
345345
#include <snippets-data-sections.ld>
346+
/* Tag end location of code+data that shall be copied in non-XIP execution.
347+
* It must not include noinit section.
348+
*/
349+
__relocation_region_end = .;
346350

347351
#include <zephyr/linker/common-noinit.ld>
348352

soc/common/riscv-privileged/vector.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ SECTION_FUNC(vectors, __start)
2121
/* Initialize global pointer */
2222
.option push
2323
.option norelax
24+
/* Include end address of code+data that shall be copied in non-XIP execution. */
25+
la gp, __relocation_region_end
2426
la gp, __global_pointer$
2527
.option pop
2628
#endif

0 commit comments

Comments
 (0)