ARM: Fix environment setup.
authorDanny Milosavljevic <dannym@scratchpost.org>
Mon, 11 Mar 2019 10:53:09 +0000 (11:53 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 9 Sep 2019 16:34:01 +0000 (18:34 +0200)
* lib/linux/arm-mes-gcc/crt1.c (_start): Fix environment setup.

lib/linux/arm-mes-gcc/crt1.c

index a54ed0207f409d12986dabcfb5924d108e62018a..67e7ad29d500438424171f976ca624857fea5263 100644 (file)
@@ -54,8 +54,9 @@ _start ()
   asm (
        "ldr     r0,[fp,#4]\n\t" /* r0 = argc */
        "add     r1,fp,#8\n\t" /* r1 = &argv[0] */
-       "add     r2,r1,#1\n\t" /* r2 = r1 + 1 */
-       "lsl     r2,#2\n\t" /* r2 = (r1 + 1) << 2 */
+       "add     r2,r0,#1\n\t" /* r2 = r0 + 1 */
+       "lsl     r2,#2\n\t" /* r2 = (r0 + 1) << 2 */
+       "add     r2,r2,r1\n\t" /* r2 = ((r0 + 1) << 2) + r1 */
        "push    {r2}\n\t" /* envp */
        "push    {r1}\n\t" /* argv */
        "push    {r0}\n\t" /* argc */