rv8
rv8 copied to clipboard
Fix crash of statically linked Linux binaries.
Statically linked binaries will cause RV8 to crash. I searched for the cause for a while and it turns out that the source code of the glibc port (see https://github.com/riscv/riscv-glibc/blob/riscv-glibc-2.26/sysdeps/riscv/start.S) says a0 will be registered as an exit handler (probably for vDSO cleanup, though I cannot actually find anywhere in the ABI). Setting it to zero will fix the issue.
Thanks for looking into this.
I think the change should be in processor-proxy.h as it is only specific to the user-mode syscall proxy. e.g.
diff --git a/src/emu/processor-proxy.h b/src/emu/processor-proxy.h
index 8349c9e..ac610e5 100644
--- a/src/emu/processor-proxy.h
+++ b/src/emu/processor-proxy.h
@@ -22,7 +22,10 @@ namespace riscv {
const char* name() { return "rv-sim"; }
- void init() {}
+ void init()
+ {
+ P::ireg[rv_ireg_a0].r.xu.val = 0;
+ }
void destroy()
{