From c0b4a7b25430e4495bb213a5c3ad43e26c6bff20 Mon Sep 17 00:00:00 2001 From: Ruinland ChuanTzu Tsai Date: Mon, 2 Dec 2019 19:06:52 +0800 Subject: 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. --- src/fenv/riscv64/fenv.S | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1