Skip to content

Commit

Permalink
libgloss: riscv: Fix envp parameter for main
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bernd Edlinger authored and github-cygwin committed Apr 12, 2024
1 parent 579064b commit 730703b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libgloss/riscv/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 730703b

Please sign in to comment.