Module Name:    src
Committed By:   joerg
Date:           Thu Jun 30 19:48:43 UTC 2011

Modified Files:
        src/lib/csu/arch/i386: crt0.S
        src/lib/csu/arch/x86_64: crt0.S
        src/lib/csu/common: crt0-common.c

Log Message:
Assert that ps_strings is valid. Use it to drop the first three
arguments to ___start to make the assembler callers simpler.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/i386/crt0.S
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/x86_64/crt0.S
cvs rdiff -u -r1.5 -r1.6 src/lib/csu/common/crt0-common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/csu/arch/i386/crt0.S
diff -u src/lib/csu/arch/i386/crt0.S:1.1 src/lib/csu/arch/i386/crt0.S:1.2
--- src/lib/csu/arch/i386/crt0.S:1.1	Sat Aug  7 18:01:33 2010
+++ src/lib/csu/arch/i386/crt0.S	Thu Jun 30 19:48:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.2 2011/06/30 19:48:43 joerg Exp $ */
 
 /*
  * Copyright (c) 1998 Christos Zoulas
@@ -37,17 +37,11 @@
 
 #include <machine/asm.h>
 
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
+RCSID("$NetBSD: crt0.S,v 1.2 2011/06/30 19:48:43 joerg Exp $")
 
 STRONG_ALIAS(_start,__start)
 _ENTRY(__start)
 	pushl	%ebx
 	pushl	%ecx
 	pushl	%edx
-	movl	12(%esp),%eax
-	leal	16(%esp),%edx
-	leal	20(%esp,%eax,4),%ecx
-	pushl	%ecx
-	pushl	%edx
-	pushl	%eax
 	call	___start

Index: src/lib/csu/arch/x86_64/crt0.S
diff -u src/lib/csu/arch/x86_64/crt0.S:1.1 src/lib/csu/arch/x86_64/crt0.S:1.2
--- src/lib/csu/arch/x86_64/crt0.S:1.1	Sat Aug  7 18:01:34 2010
+++ src/lib/csu/arch/x86_64/crt0.S	Thu Jun 30 19:48:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
+/* $NetBSD: crt0.S,v 1.2 2011/06/30 19:48:43 joerg Exp $ */
 
 /*
  * Copyright (c) 1998 Christos Zoulas
@@ -35,18 +35,14 @@
 
 #include <machine/asm.h>
 
-RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
+RCSID("$NetBSD: crt0.S,v 1.2 2011/06/30 19:48:43 joerg Exp $")
 
 STRONG_ALIAS(_start,__start)
 
 _ENTRY(__start)
-	movq	%rbx,%r9
-	movq	%rcx,%r8
-	movq	%rdx,%rcx
-	movq	(%rsp),%rdi
-	leaq	16(%rsp,%rdi,8),%rdx
-	leaq	8(%rsp),%rsi
-	subq	$8,%rsp
-	andq	$~15,%rsp
-	addq	$8,%rsp
+	andq    $~15,%rsp
+	subq    $8,%rsp
+	movq	%rdx, %rdi
+	movq	%rcx, %rsi
+	movq	%rbx, %rdx
 	jmp	___start

Index: src/lib/csu/common/crt0-common.c
diff -u src/lib/csu/common/crt0-common.c:1.5 src/lib/csu/common/crt0-common.c:1.6
--- src/lib/csu/common/crt0-common.c:1.5	Mon Mar  7 05:09:09 2011
+++ src/lib/csu/common/crt0-common.c	Thu Jun 30 19:48:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0-common.c,v 1.5 2011/03/07 05:09:09 joerg Exp $ */
+/* $NetBSD: crt0-common.c,v 1.6 2011/06/30 19:48:43 joerg Exp $ */
 
 /*
  * Copyright (c) 1998 Christos Zoulas
@@ -36,9 +36,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: crt0-common.c,v 1.5 2011/03/07 05:09:09 joerg Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.6 2011/06/30 19:48:43 joerg Exp $");
 
 #include <sys/types.h>
+#include <sys/exec.h>
 #include <sys/syscall.h>
 #include <machine/profile.h>
 #include <stdlib.h>
@@ -73,8 +74,8 @@
 static char	 empty_string[] = "";
 char		*__progname = empty_string;
 
-void		___start(int, char **, char **, void (*)(void),
-    const Obj_Entry *, struct ps_strings *);
+void		___start(void (*)(void), const Obj_Entry *,
+			 struct ps_strings *);
 
 #define	write(fd, s, n)	__syscall(SYS_write, (fd), (s), (n))
 
@@ -85,17 +86,21 @@
 } while (0)
 
 void
-___start(int argc, char **argv, char **envp,
-    void (*cleanup)(void),			/* from shared loader */
+___start(void (*cleanup)(void),			/* from shared loader */
     const Obj_Entry *obj,			/* from shared loader */
     struct ps_strings *ps_strings)
 {
-	environ = envp;
 
-	if (argv[0] != NULL) {
+	if (ps_strings == NULL)
+		_FATAL("ps_strings missing\n");
+	__ps_strings = ps_strings;
+
+	environ = ps_strings->ps_envstr;
+
+	if (ps_strings->ps_argvstr[0] != NULL) {
 		char *c;
-		__progname = argv[0];
-		for (c = argv[0]; *c; ++c) {
+		__progname = ps_strings->ps_argvstr[0];
+		for (c = ps_strings->ps_argvstr[0]; *c; ++c) {
 			if (*c == '/')
 				__progname = c + 1;
 		}
@@ -103,9 +108,6 @@
 		__progname = empty_string;
 	}
 
-	if (ps_strings != NULL)
-		__ps_strings = ps_strings;
-
 	if (&rtld_DYNAMIC != NULL) {
 		if (obj == NULL)
 			_FATAL("NULL Obj_Entry pointer in GOT\n");
@@ -126,5 +128,5 @@
 	atexit(_fini);
 	_init();
 
-	exit(main(argc, argv, environ));
+	exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ));
 }

Reply via email to