summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuinland ChuanTzu Tsai <ruinland@andestech.com>2019-12-02 19:06:52 +0800
committerRich Felker <dalias@aerifal.cx>2019-12-07 12:58:39 -0500
commitc0b4a7b25430e4495bb213a5c3ad43e26c6bff20 (patch)
tree8d86fcc16b0479db29ccf5ad1e734c5901d3e4fe
parentdaa29e894c74d61296fe19d9b7c4be2f04037639 (diff)
downloadmusl-c0b4a7b25430e4495bb213a5c3ad43e26c6bff20.tar.gz
riscv64: fix fesetenv(FE_DFL_ENV) crash
When FE_DFL_ENV is passed to fesetenv(), the very first instruction lw t1, 0(a0) will fail since a0 is -1.
-rw-r--r--src/fenv/riscv64/fenv.S5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fenv/riscv64/fenv.S b/src/fenv/riscv64/fenv.S
index f149003d..0ea78bf9 100644
--- a/src/fenv/riscv64/fenv.S
+++ b/src/fenv/riscv64/fenv.S
@@ -45,8 +45,11 @@ fegetenv:
.global fesetenv
.type fesetenv, %function
fesetenv:
+ li t2, -1
+ li t1, 0
+ beq a0, t2, 1f
lw t1, 0(a0)
- fscsr t0, t1
+1: fscsr t1
li a0, 0
ret