public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] libgloss: riscv: Fix envp parameter for main
@ 2024-04-12 9:44 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-04-12 9:44 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=730703bdb8e1ae671517efaa0b9e273eef52d724
commit 730703bdb8e1ae671517efaa0b9e273eef52d724
Author: Bernd Edlinger <bernd@edlinger-online.de>
AuthorDate: Thu Apr 11 14:57:11 2024 +0200
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Apr 12 11:44:07 2024 +0200
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.
Diff:
---
libgloss/riscv/crt0.S | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S
index f1c5419a5eb4..54443e4129dc 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-12 9:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12 9:44 [newlib-cygwin/main] libgloss: riscv: Fix envp parameter for main Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).