From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id CC0F73858417; Fri, 12 Apr 2024 09:44:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC0F73858417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712915091; bh=gJA8eLOfubb/61AHyGvRi7iaq8P7ua0bcoV+VFn7Euc=; h=From:To:Subject:Date:From; b=IgvY53rHS0jSD/TRWv7UTwg+OVvIwCO2FvhXj95hL9mZMqqsu2VCvRruoEwmxMId4 q7FDrfZWyymQIYFi8miOruJY65511jdD8edVjK6A92bSTX/O8dnVhiJI0ogfgTc0FN nW1L71SUk+PIF/BmNSGm9Gxjeje+qykFwN97mdPI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] libgloss: riscv: Fix envp parameter for main X-Act-Checkin: newlib-cygwin X-Git-Author: Bernd Edlinger X-Git-Refname: refs/heads/main X-Git-Oldrev: 579064bf4d408e99ed7556f36a3050c7ee99dee6 X-Git-Newrev: 730703bdb8e1ae671517efaa0b9e273eef52d724 Message-Id: <20240412094451.CC0F73858417@sourceware.org> Date: Fri, 12 Apr 2024 09:44:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D730703bdb8e= 1ae671517efaa0b9e273eef52d724 commit 730703bdb8e1ae671517efaa0b9e273eef52d724 Author: Bernd Edlinger AuthorDate: Thu Apr 11 14:57:11 2024 +0200 Commit: Corinna Vinschen CommitDate: Fri Apr 12 11:44:07 2024 +0200 libgloss: riscv: Fix envp parameter for main =20 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: =20 lw a0, 0(sp) # a0 =3D argc addi a1, sp, __SIZEOF_POINTER__ # a1 =3D argv - li a2, 0 # a2 =3D envp =3D NULL + slli a2, a0, 1 + __SIZEOF_POINTER__ >> 2 + addi a2, a2, __SIZEOF_POINTER__ + add a2, a2, a1 # a2 =3D envp call main tail exit .size _start, .-_start