Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/misc PR 51654: Don't initialize _dlauxinfo for stat...



details:   https://anonhg.NetBSD.org/src/rev/b9688e499ef8
branches:  trunk
changeset: 354463:b9688e499ef8
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Jun 17 15:26:44 2017 +0000

description:
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.

diffstat:

 lib/libc/misc/initfini.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r b4178c9bef85 -r b9688e499ef8 lib/libc/misc/initfini.c
--- a/lib/libc/misc/initfini.c  Sat Jun 17 12:41:20 2017 +0000
+++ b/lib/libc/misc/initfini.c  Sat Jun 17 15:26:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initfini.c,v 1.13 2016/11/26 21:17:06 dholland Exp $    */
+/*     $NetBSD: initfini.c,v 1.14 2017/06/17 15:26:44 joerg 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.14 2017/06/17 15:26:44 joerg Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
@@ -58,6 +58,7 @@
 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_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;
 



Home | Main Index | Thread Index | Old Index