Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc Ensure that initfini.c is referenced by exit.c. The...



details:   https://anonhg.NetBSD.org/src/rev/ae2969128368
branches:  trunk
changeset: 755925:ae2969128368
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Jun 28 21:58:02 2010 +0000

description:
Ensure that initfini.c is referenced by exit.c. The start up code has to
reference the latter as a return of main() results in a call to exit(3),
so this ensures that the libc constructors are run for statically linked
programs. Fixes PR 37454.

diffstat:

 lib/libc/misc/initfini.c |   8 ++++----
 lib/libc/stdlib/exit.c   |  12 ++++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diffs (73 lines):

diff -r 79fa0c924502 -r ae2969128368 lib/libc/misc/initfini.c
--- a/lib/libc/misc/initfini.c  Mon Jun 28 19:32:43 2010 +0000
+++ b/lib/libc/misc/initfini.c  Mon Jun 28 21:58:02 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initfini.c,v 1.5 2008/04/28 20:23:00 martin Exp $       */
+/*     $NetBSD: initfini.c,v 1.6 2010/06/28 21:58:02 joerg Exp $        */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,13 +30,13 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: initfini.c,v 1.5 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: initfini.c,v 1.6 2010/06/28 21:58:02 joerg Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
 #endif
 
-static void    __libc_init(void) __attribute__((__constructor__, __used__));
+void   __libc_init(void) __attribute__((__constructor__, __used__));
 
 void   __guard_setup(void);
 void   __libc_thr_init(void);
@@ -44,7 +44,7 @@
 void   __libc_atexit_init(void);
 
 /* LINTED used */
-static void
+void
 __libc_init(void)
 {
 
diff -r 79fa0c924502 -r ae2969128368 lib/libc/stdlib/exit.c
--- a/lib/libc/stdlib/exit.c    Mon Jun 28 19:32:43 2010 +0000
+++ b/lib/libc/stdlib/exit.c    Mon Jun 28 21:58:02 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exit.c,v 1.11 2007/10/30 17:19:59 skrll Exp $  */
+/*     $NetBSD: exit.c,v 1.12 2010/06/28 21:58:02 joerg Exp $  */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)exit.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: exit.c,v 1.11 2007/10/30 17:19:59 skrll Exp $");
+__RCSID("$NetBSD: exit.c,v 1.12 2010/06/28 21:58:02 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -45,14 +45,18 @@
 #include "atexit.h"
 #endif
 
+extern void __libc_init(void);
+#ifndef __lint
+static void (*force_ref)(void) __used = __libc_init;
+#endif
+
 void (*__cleanup) __P((void));
 
 /*
  * Exit, flushing stdio buffers if necessary.
  */
 void
-exit(status)
-       int status;
+exit(int status)
 {
 
 #ifdef _LIBC



Home | Main Index | Thread Index | Old Index