diff options
author | Hau Hsu <hau.hsu@sifive.com> | 2024-01-05 15:06:39 +0800 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-01-08 13:12:06 +0100 |
commit | 573458e7fc4f5247874b139a17e7e54827c92440 (patch) | |
tree | 1a13753c49be46c6ab64db903f9e9a9487898251 /libgloss/riscv | |
parent | 94d871eeac43657090138653ececd49dc97ee631 (diff) | |
download | newlib-573458e7fc4f5247874b139a17e7e54827c92440.zip newlib-573458e7fc4f5247874b139a17e7e54827c92440.tar.gz newlib-573458e7fc4f5247874b139a17e7e54827c92440.tar.bz2 |
RISC-V: Initialize the jvt CSR
Set symbol '__jvt_base$' as weak. So if the symbol is not set in the
linker script, the address would be 0. We initialize jvt CSR only if
the address is not 0.
Also use csr number directly instead of using symbolic name to prevent the
backward incompatible issue.
psabi reference:
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation
Diffstat (limited to 'libgloss/riscv')
-rw-r--r-- | libgloss/riscv/crt0.S | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S index 7a4e4e3..f1c5419 100644 --- a/libgloss/riscv/crt0.S +++ b/libgloss/riscv/crt0.S @@ -26,6 +26,17 @@ _start: addi gp, gp, %pcrel_lo(1b) .option pop + /* Initialize jvt CSR (reg addr: 0x0017) */ + .weak __jvt_base$ + lla a0, __jvt_base$ + beqz a0, .Ljvt_init_end +.option push +.option norelax +.option arch, +zicsr + csrw 0x17, a0 +.option pop +.Ljvt_init_end: + # Clear the bss segment la a0, __bss_start la a2, _end |