Module Name:    src
Committed By:   snj
Date:           Wed Jun 21 17:46:02 UTC 2017

Modified Files:
        src/lib/libc/misc [netbsd-8]: initfini.c

Log Message:
Pull up following revision(s) (requested by joerg in ticket #44):
        lib/libc/misc/initfini.c: revision 1.14
PR 51654: Don't initialize _dlauxinfo for static binaries.
Emacs likes save all memory of the main binary and the first run of
_libc_init via .init will get the wrong (old) value of __ps_strings.
By avoiding the initialization of _dlauxinfo for shared applications,
it will be touched only by the _libc_init call from crt0.o itself,
at which point __ps_strings is correct.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.6.1 src/lib/libc/misc/initfini.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/libc/misc/initfini.c
diff -u src/lib/libc/misc/initfini.c:1.13 src/lib/libc/misc/initfini.c:1.13.6.1
--- src/lib/libc/misc/initfini.c:1.13	Sat Nov 26 21:17:06 2016
+++ src/lib/libc/misc/initfini.c	Wed Jun 21 17:46:02 2017
@@ -1,4 +1,4 @@
-/* 	$NetBSD: initfini.c,v 1.13 2016/11/26 21:17:06 dholland Exp $	 */
+/* 	$NetBSD: initfini.c,v 1.13.6.1 2017/06/21 17:46:02 snj Exp $	 */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: initfini.c,v 1.13 2016/11/26 21:17:06 dholland Exp $");
+__RCSID("$NetBSD: initfini.c,v 1.13.6.1 2017/06/21 17:46:02 snj Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
@@ -58,6 +58,7 @@ __weak_alias(_dlauxinfo,___dlauxinfo)
 static void *__libc_dlauxinfo;
 
 void *___dlauxinfo(void) __pure;
+__weakref_visible void * real_dlauxinfo(void) __weak_reference(_dlauxinfo);
 
 void *
 ___dlauxinfo(void)
@@ -107,7 +108,8 @@ _libc_init(void)
 
 	libc_initialised = 1;
 
-	if (__ps_strings != NULL)
+	/* Only initialize _dlauxinfo for static binaries. */
+	if (__ps_strings != NULL && real_dlauxinfo == ___dlauxinfo)
 		__libc_dlauxinfo = __ps_strings->ps_argvstr +
 		    __ps_strings->ps_nargvstr + __ps_strings->ps_nenvstr + 2;
 

Reply via email to