From e883e926dff8713acae129977ba3587347bd3acd Mon Sep 17 00:00:00 2001 From: joerg Date: Mon, 28 Jun 2010 21:58:02 +0000 Subject: [PATCH] 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. --- lib/libc/misc/initfini.c | 8 ++++---- lib/libc/stdlib/exit.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/libc/misc/initfini.c b/lib/libc/misc/initfini.c index 10abacd2fc67..d23edb7e3663 100644 --- a/lib/libc/misc/initfini.c +++ b/lib/libc/misc/initfini.c @@ -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 -__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_atomic_init(void); void __libc_atexit_init(void); /* LINTED used */ -static void +void __libc_init(void) { diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index ebb0e3e0fdc1..089c54859a58 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -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 @@ __RCSID("$NetBSD: exit.c,v 1.11 2007/10/30 17:19:59 skrll Exp $"); #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