Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Jul 2002 12:49:43 +0100
From:      Mark Murray <mark@grondar.za>
To:        audit@freebsd.org
Subject:   lib/csu diff-reduction, take #3 (commit candidate)
Message-ID:  <200207081149.g68Bnhqw027827@grimreaper.grondar.org>

next in thread | raw e-mail | index | archive | help
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <27824.1026128943.1@grimreaper.grondar.org>

Hi

I've made some more asked-for changes to my lib/csu/*/crt1.c diffs;
here they are.

Please review these as commit candidates.

Thanks!

M
-- 
o       Mark Murray
\_
O.\_    Warning: this .sig is umop ap!sdn

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <27824.1026128943.2@grimreaper.grondar.org>
Content-Description: lib/csu diffs

Index: alpha/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/alpha/crt1.c,v
retrieving revision 1.13
diff -u -d -r1.13 crt1.c
--- alpha/crt1.c	25 Jun 2002 18:01:12 -0000	1.13
+++ alpha/crt1.c	7 Jul 2002 12:33:22 -0000
@@ -1,5 +1,5 @@
-/*
- * Copyright 2001 David E. O'Brien
+/*-
+ * Copyright 2001 David E. O'Brien.
  * All rights reserved.
  * Copyright 1996-1998 John D. Polstra.
  * All rights reserved.
@@ -35,22 +35,25 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef lint
 #ifndef __GNUC__
 #error "GCC is needed to compile this file"
 #endif
+#endif /* lint */
 
 #include <stdlib.h>
+
 #include "libc_private.h"
 #include "crtbrand.c"
 
 struct Struct_Obj_Entry;
 struct ps_strings;
 
-#pragma weak _DYNAMIC
 extern int _DYNAMIC;
+#pragma weak _DYNAMIC
 
-extern void _init(void);
 extern void _fini(void);
+extern void _init(void);
 extern int main(int, char **, char **);
 extern void _start(char **, void (*)(void), struct Struct_Obj_Entry *,
     struct ps_strings *);
@@ -66,18 +69,17 @@
 const char *__progname = "";
 
 /* The entry function. */
+/* ARGSUSED */
 void
-_start(char **ap,
-	void (*cleanup)(void),			/* from shared loader */
-	struct Struct_Obj_Entry *obj __unused,	/* from shared loader */
-	struct ps_strings *ps_strings __unused)
+_start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused,
+    struct ps_strings *ps_strings __unused)
 {
 	int argc;
 	char **argv;
 	char **env;
 	const char *s;
 
-	argc = * (long *) ap;
+	argc = *(long *)(void *)ap;
 	argv = ap + 1;
 	env  = ap + 2 + argc;
 	environ = env;
Index: i386-elf/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/i386-elf/crt1.c,v
retrieving revision 1.8
diff -u -d -r1.8 crt1.c
--- i386-elf/crt1.c	3 Jul 2002 14:42:39 -0000	1.8
+++ i386-elf/crt1.c	3 Jul 2002 14:59:27 -0000
@@ -23,21 +23,26 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef lint
 #ifndef __GNUC__
 #error "GCC is needed to compile this file"
 #endif
+#endif /* lint */
 
-#include <stddef.h>
 #include <stdlib.h>
 
 #include "libc_private.h"
 #include "crtbrand.c"
 
+extern int _DYNAMIC;
+#pragma weak _DYNAMIC
+
 typedef void (*fptr)(void);
 
 extern void _fini(void);
 extern void _init(void);
 extern int main(int, char **, char **);
+extern void _start(char *, ...);
 
 #ifdef GCRT
 extern void _mcleanup(void);
@@ -46,33 +51,35 @@
 extern int etext;
 #endif
 
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
+char **environ;
+const char *__progname = "";
 
-#ifdef __i386__
-#define get_rtld_cleanup()				\
-	({ fptr __value;				\
-	    __asm__("movl %%edx,%0" : "=rm"(__value));	\
-	    __value; })
+static __inline fptr
+get_rtld_cleanup(void)
+{
+	fptr retval;
+
+#ifdef	__GNUC__
+	__asm__("movl %%edx,%0" : "=rm"(retval));
 #else
-#error "This file only supports the i386 architecture"
+	retval = (fptr)0; /* XXXX Fix this for other compilers */
 #endif
+	return(retval);
+}
 
-char **environ;
-const char *__progname = "";
-
+/* The entry function. */
 void
-_start(char *arguments, ...)
+_start(char *ap, ...)
 {
-	fptr rtld_cleanup;
+	fptr cleanup;
 	int argc;
 	char **argv;
 	char **env;
 	const char *s;
 
-	rtld_cleanup = get_rtld_cleanup();
-	argv = &arguments;
-	argc = * (int *) (argv - 1);
+	cleanup = get_rtld_cleanup();
+	argv = &ap;
+	argc = *(long *)(void *)(argv - 1);
 	env = argv + argc + 1;
 	environ = env;
 	if (argc > 0 && argv[0] != NULL) {
@@ -83,7 +90,7 @@
 	}
 
 	if (&_DYNAMIC != NULL)
-		atexit(rtld_cleanup);
+		atexit(cleanup);
 
 #ifdef GCRT
 	atexit(_mcleanup);
Index: ia64/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/ia64/crt1.c,v
retrieving revision 1.7
diff -u -d -r1.7 crt1.c
--- ia64/crt1.c	29 Mar 2002 22:43:41 -0000	1.7
+++ ia64/crt1.c	7 Jul 2002 12:10:32 -0000
@@ -31,11 +31,14 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef lint
 #ifndef __GNUC__
 #error "GCC is needed to compile this file"
 #endif
+#endif /* lint */
 
 #include <stdlib.h>
+
 #include "libc_private.h"
 #include "crtbrand.c"
 
@@ -45,9 +48,10 @@
 #pragma weak _DYNAMIC
 extern int _DYNAMIC;
 
-extern void _init(void);
 extern void _fini(void);
+extern void _init(void);
 extern int main(int, char **, char **);
+extern void _start(char **, struct ps_strings *, void (*)(void));
 
 #ifdef GCRT
 extern void _mcleanup(void);
@@ -59,17 +63,10 @@
 char **environ;
 const char *__progname = "";
 
-/* The entry function. */
-void
-_start(char **ap,
-       struct ps_strings *ps_strings,
-       void (*cleanup)(void))
+static __inline void
+fix_gp(void)
 {
-	int argc;
-	char **argv;
-	char **env;
-	const char *s;
-
+#ifdef __GNUC__
 	/* Calculate gp */
 	__asm __volatile(" \
 		movl gp=@gprel(1f) ; \
@@ -78,8 +75,21 @@
 		;; ; \
 		sub gp=r14,gp ; \
 		;; ");
+#endif
+}
 
-	argc = * (long *) ap;
+/* The entry function. */
+/* ARGSUSED */
+void
+_start(char **ap, struct ps_strings *ps_strings __unused, void (*cleanup)(void))
+{
+	int argc;
+	char **argv;
+	char **env;
+	const char *s;
+
+	fix_gp();
+	argc = *(long *)(void *)ap;
 	argv = ap + 1;
 	env  = ap + 2 + argc;
 	environ = env;
Index: powerpc/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/powerpc/crt1.c,v
retrieving revision 1.8
diff -u -d -r1.8 crt1.c
--- powerpc/crt1.c	29 Mar 2002 22:43:41 -0000	1.8
+++ powerpc/crt1.c	7 Jul 2002 12:38:19 -0000
@@ -38,23 +38,28 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef lint
 #ifndef __GNUC__
 #error "GCC is needed to compile this file"
 #endif
+#endif /* lint */
 
 #include <stdlib.h>
+
 #include "libc_private.h"
 #include "crtbrand.c"
 
 struct Struct_Obj_Entry;
 struct ps_strings;
 
-#pragma weak _DYNAMIC
 extern int _DYNAMIC;
+#pragma weak _DYNAMIC
 
-extern void _init(void);
 extern void _fini(void);
+extern void _init(void);
 extern int main(int, char **, char **);
+extern void _start(int, char **, char **, const struct Struct_Obj_Entry *,
+    void (*)(void), struct ps_strings *);
 
 #ifdef GCRT
 extern void _mcleanup(void);
@@ -67,23 +72,20 @@
 const char *__progname = "";
 struct ps_strings *__ps_strings;
 
-/* The entry function.
- *
+/* The entry function. */
+/*
  * First 5 arguments are specified by the PowerPC SVR4 ABI.
  * The last argument, ps_strings, is a BSD extension.
  */
+/* ARGSUSED */
 void
-_start(argc, argv, envp, obj, cleanup, ps_strings)
-	int argc;
-	char **argv, **envp;
-	const struct Struct_Obj_Entry *obj;	/* from shared loader */
-	void (*cleanup)(void);			/* from shared loader */
-	struct ps_strings *ps_strings;		/* BSD extension */
+_start(int argc, char **argv, char **env,
+    const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void),
+    struct ps_strings *ps_strings)
 {
-	char *namep;
 	const char *s;
 
-	environ = envp;
+	environ = env;
 
 	if (argc > 0 && argv[0] != NULL) {
 		__progname = argv[0];
@@ -106,7 +108,7 @@
 	monstartup(&eprol, &etext);
 #endif
 	_init();
-	exit( main(argc, argv, envp) );
+	exit( main(argc, argv, env) );
 }
 
 #ifdef GCRT
Index: sparc64/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/sparc64/crt1.c,v
retrieving revision 1.8
diff -u -d -r1.8 crt1.c
--- sparc64/crt1.c	29 Apr 2002 20:25:29 -0000	1.8
+++ sparc64/crt1.c	7 Jul 2002 12:34:38 -0000
@@ -1,5 +1,5 @@
-/*
- * Copyright 2001 David E. O'Brien
+/*-
+ * Copyright 2001 David E. O'Brien.
  * All rights reserved.
  * Copyright (c) 1995, 1998 Berkeley Software Design, Inc.
  * All rights reserved.
@@ -29,25 +29,32 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef lint
 #ifndef __GNUC__
 #error "GCC is needed to compile this file"
 #endif
+#endif /* lint */
 
 #include <stdlib.h>
+
 #include "libc_private.h"
 #include "crtbrand.c"
 
 struct Struct_Obj_Entry;
 struct ps_strings;
 
-#pragma weak _DYNAMIC
 extern int _DYNAMIC;
+#pragma weak _DYNAMIC
+
+typedef void (*fptr)(void);
 
-extern void _init(void);
 extern void _fini(void);
+extern void _init(void);
 extern int main(int, char **, char **);
-extern void __sparc64_sigtramp_setup(void);
-extern void __sparc64_utrap_setup(void);
+extern void _start(char **, void (*)(void), struct Struct_Obj_Entry *, 
+    struct ps_strings *);
+extern void __sparc_sigtramp_setup(void);
+extern void __sparc_utrap_setup(void);
 
 #ifdef GCRT
 extern void _mcleanup(void);
@@ -59,9 +66,30 @@
 char **environ;
 const char *__progname = "";
 
+/*
+ * Grab %g1 before it gets used for anything by the compiler.
+ * Sparc ELF psABI specifies a termination routine (if any) will be in
+ * %g1
+ */
+static __inline fptr
+get_term(void)
+{
+	fptr retval;
+
+#if 0
+#ifdef	__GNUC__
+	__asm__ volatile("mov %%g1,%0" : "=r"(retval));
+#else
+	retval = (fptr)0; /* XXXX Fix this for other compilers */
+#endif
+#else
+	retval = (fptr)0; /* XXXX temporary */
+#endif
+	return(retval);
+}
+
 /* The entry function. */
 /*
- *
  * %o0 holds ps_strings pointer.  For Solaris compat and/or shared
  * libraries, if %g1 is not 0, it is a routine to pass to atexit().
  * (By passing the pointer in the usual argument register, we avoid
@@ -70,26 +98,20 @@
  * Note: kernel may (is not set in stone yet) pass ELF aux vector in %o1,
  * but for now we do not use it here.
  */
+/* ARGSUSED */
 void
-_start(char **ap,
-	void (*cleanup)(void),			/* from shared loader */
-	struct Struct_Obj_Entry *obj,		/* from shared loader */
-	struct ps_strings *ps_strings)
+_start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused,
+    struct ps_strings *ps_strings __unused)
 {
+	void (*term)(void);	
 	int argc;
 	char **argv;
 	char **env;
 	const char *s;
-#if 0
-	void (*term)(void);	
 
-	/* Grab %g1 before it gets used for anything by the compiler. */
-	/* Sparc ELF psABI specifies a termination routine (if any) will be in
-	   %g1 */
-	__asm__ volatile("mov %%g1,%0" : "=r"(term));
-#endif
+	term = get_term();
 
-	argc = * (long *) ap;
+	argc = *(long *)(void *)ap;
 	argv = ap + 1;
 	env  = ap + 2 + argc;
 	environ = env;
@@ -102,14 +124,13 @@
 
 	__sparc_sigtramp_setup();
 	__sparc_utrap_setup();
-#if 0
+
 	/*
 	 * If the kernel or a shared library wants us to call
 	 * a termination function, arrange to do so.
 	 */
 	if (term)
 		atexit(term);
-#endif
 
 	if (&_DYNAMIC != NULL)
 		atexit(cleanup);

------- =_aaaaaaaaaa0--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207081149.g68Bnhqw027827>