diff options
author | Bernd Edlinger <bernd@edlinger-online.de> | 2024-04-11 14:57:11 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-04-12 11:44:07 +0200 |
commit | 730703bdb8e1ae671517efaa0b9e273eef52d724 (patch) | |
tree | 8a647da529f300213c21343ba744b4b2242fcb63 | |
parent | 579064bf4d408e99ed7556f36a3050c7ee99dee6 (diff) | |
download | newlib-730703bdb8e1ae671517efaa0b9e273eef52d724.zip newlib-730703bdb8e1ae671517efaa0b9e273eef52d724.tar.gz newlib-730703bdb8e1ae671517efaa0b9e273eef52d724.tar.bz2 |
libgloss: riscv: Fix envp parameter for main
The envp paramter is currently NULL when crt0.S calls main.
With this patch the envp parameter should now be set correctly.
Tested with riscv32 and riscv64: both gdb/sim and qemu do work.
-rw-r--r-- | libgloss/riscv/crt0.S | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S index f1c5419..54443e4 100644 --- a/libgloss/riscv/crt0.S +++ b/libgloss/riscv/crt0.S @@ -61,7 +61,9 @@ _start: lw a0, 0(sp) # a0 = argc addi a1, sp, __SIZEOF_POINTER__ # a1 = argv - li a2, 0 # a2 = envp = NULL + slli a2, a0, 1 + __SIZEOF_POINTER__ >> 2 + addi a2, a2, __SIZEOF_POINTER__ + add a2, a2, a1 # a2 = envp call main tail exit .size _start, .-_start |