From: Ben Gras Date: Wed, 9 Jun 2010 12:10:31 +0000 (+0000) Subject: crtso.S: save *argv[] and argc globally, to be used by getprogname(). X-Git-Tag: v3.1.8~475 X-Git-Url: http://zhaoyanbai.com/repos/%22/xml/v3/zones/static/man.host.html?a=commitdiff_plain;h=c04695874595bd43e98207096ec1cfd04d5ff14e;p=minix.git crtso.S: save *argv[] and argc globally, to be used by getprogname(). --- 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. */