From c04695874595bd43e98207096ec1cfd04d5ff14e Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 9 Jun 2010 12:10:31 +0000 Subject: [PATCH] crtso.S: save *argv[] and argc globally, to be used by getprogname(). --- lib/csu/i386/crtso.S | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/csu/i386/crtso.S b/lib/csu/i386/crtso.S index 599d49966..5ae4cb16a 100644 --- a/lib/csu/i386/crtso.S +++ b/lib/csu/i386/crtso.S @@ -23,7 +23,7 @@ begdata: .bss begbss: -.globl crtso, __penviron, __penvp +.globl crtso, __penviron, __penvp, ___prognamep, ___argc .globl __minix_datastart, __minix_mainjump, __minix_unmapzero .extern _main, _exit @@ -57,6 +57,13 @@ crtso: movl __penviron, %ebx movl %ecx, (%ebx) /* *_penviron = envp; */ + /* Save argv[] and argc. This is so that we can return + * argv[0] in the future, without having to check whether + * argv can be dereferenced safely now. + */ + mov %edx, (___prognamep) + mov %eax, (___argc) + push %ecx /* push envp */ push %edx /* push argv */ push %eax /* push argc */ @@ -108,8 +115,11 @@ __minix_datastart: .data __penviron: .long __penvp /* Pointer to environ, or hidden pointer */ - .bss +___prognamep: +.space 4 +___argc: +.space 4 .lcomm __penvp, 4 /* Hidden environment vector */ .extern endtext /* Force loading of end labels. */