Skip to content

Commit 23605f5

Browse files
committed
Assure address of PC at startup.
1 parent cd419ae commit 23605f5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

riscv-rt/asm.S

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
.global _start
1313

1414
_start:
15+
/* Jump to the absolute address defined by the linker script. */
16+
// for 32bit
17+
.if __riscv_xlen == 32
18+
lui ra, %hi(_abs_start)
19+
jr %lo(_abs_start)(ra)
20+
.endif
21+
22+
// for 64bit
23+
.if __riscv_xlen == 64
24+
1:
25+
auipc ra, %pcrel_hi(1f)
26+
ld ra, %pcrel_lo(1b)(ra)
27+
jr ra
28+
.align 3
29+
1:
30+
.dword _abs_start
31+
.endif
32+
33+
_abs_start:
1534
.cfi_startproc
1635
.cfi_undefined ra
1736

0 commit comments

Comments
 (0)