Module Name:    src
Committed By:   roy
Date:           Thu Mar 18 22:17:55 UTC 2010

Modified Files:
        src/libexec/ld.elf_so: Makefile rtld.c rtld.h symbol.c

Log Message:
Use alloca(3) instead of local xmalloc for creating our DoneLists.
This allows threaded programs to use us a little better, PR lib/43005.
We need to disable SSP when using alloca.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/libexec/ld.elf_so/Makefile
cvs rdiff -u -r1.129 -r1.130 src/libexec/ld.elf_so/rtld.c
cvs rdiff -u -r1.89 -r1.90 src/libexec/ld.elf_so/rtld.h
cvs rdiff -u -r1.51 -r1.52 src/libexec/ld.elf_so/symbol.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ld.elf_so/Makefile
diff -u src/libexec/ld.elf_so/Makefile:1.93 src/libexec/ld.elf_so/Makefile:1.94
--- src/libexec/ld.elf_so/Makefile:1.93	Sun Dec 13 09:31:47 2009
+++ src/libexec/ld.elf_so/Makefile	Thu Mar 18 22:17:55 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.93 2009/12/13 09:31:47 mrg Exp $
+#	$NetBSD: Makefile,v 1.94 2010/03/18 22:17:55 roy Exp $
 #
 # NOTE: when changing ld.so, ensure that ldd still compiles.
 #
@@ -16,6 +16,10 @@
 .include <bsd.init.mk>			# for OBJECT_FMT definition
 .include <bsd.shlib.mk>			# for SHLINKINSTALLDIR definition
 
+# We use alloca
+USE_FORT=	no
+USE_SSP=	no
+
 .if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
     exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
 ARCHSUBDIR=	${LDELFSO_MACHINE_CPU}

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.129 src/libexec/ld.elf_so/rtld.c:1.130
--- src/libexec/ld.elf_so/rtld.c:1.129	Sat Feb 27 11:16:38 2010
+++ src/libexec/ld.elf_so/rtld.c	Thu Mar 18 22:17:55 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.129 2010/02/27 11:16:38 roy Exp $	 */
+/*	$NetBSD: rtld.c,v 1.130 2010/03/18 22:17:55 roy Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.129 2010/02/27 11:16:38 roy Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.130 2010/03/18 22:17:55 roy Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -822,8 +822,6 @@
 	def = _rtld_symlook_list(name, hash, &_rtld_list_main, &obj, false,
 	    &donelist);
 
-	_rtld_donelist_clear(&donelist);
-
 	if (def != NULL)
 		return obj->relocbase + def->st_value;
 	return(NULL);
@@ -919,10 +917,8 @@
 			_rtld_donelist_init(&depth);
 			def = _rtld_symlook_needed(name, hash, &fake, &defobj,
 			    false, &donelist, &depth);
-			_rtld_donelist_clear(&depth);
 		}
 
-		_rtld_donelist_clear(&donelist);
 		break;
 	}
 	

Index: src/libexec/ld.elf_so/rtld.h
diff -u src/libexec/ld.elf_so/rtld.h:1.89 src/libexec/ld.elf_so/rtld.h:1.90
--- src/libexec/ld.elf_so/rtld.h:1.89	Sat Feb 27 11:16:38 2010
+++ src/libexec/ld.elf_so/rtld.h	Thu Mar 18 22:17:55 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.h,v 1.89 2010/02/27 11:16:38 roy Exp $	 */
+/*	$NetBSD: rtld.h,v 1.90 2010/03/18 22:17:55 roy Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -61,13 +61,14 @@
 
 /*
  * Fill in a DoneList with an allocation large enough to hold all of
- * the currently-loaded objects.
+ * the currently-loaded objects. Keep this in a macro since it calls
+ * alloca and we want that to occur within the scope of the caller.
  */
-#define _rtld_donelist_init(dlp)						\
-    ((dlp)->objs = xmalloc(_rtld_objcount * sizeof((dlp)->objs[0])),	\
-    (dlp)->num_alloc = _rtld_objcount,					\
+#define _rtld_donelist_init(dlp)					\
+    ((dlp)->num_alloc = _rtld_objcount,					\
+    (dlp)->objs = alloca((dlp)->num_alloc * sizeof((dlp)->objs[0])),	\
+    assert((dlp)->objs != NULL),					\
     (dlp)->num_used = 0)
-#define _rtld_donelist_clear(dlp)		xfree((dlp)->objs)
 
 #endif /* _RTLD_SOURCE */
 

Index: src/libexec/ld.elf_so/symbol.c
diff -u src/libexec/ld.elf_so/symbol.c:1.51 src/libexec/ld.elf_so/symbol.c:1.52
--- src/libexec/ld.elf_so/symbol.c:1.51	Sat Feb 27 11:16:38 2010
+++ src/libexec/ld.elf_so/symbol.c	Thu Mar 18 22:17:55 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: symbol.c,v 1.51 2010/02/27 11:16:38 roy Exp $	 */
+/*	$NetBSD: symbol.c,v 1.52 2010/03/18 22:17:55 roy Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: symbol.c,v 1.51 2010/02/27 11:16:38 roy Exp $");
+__RCSID("$NetBSD: symbol.c,v 1.52 2010/03/18 22:17:55 roy Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -479,8 +479,6 @@
 		}
 	}
 
-	_rtld_donelist_clear(&donelist);
-
 	if (def != NULL)
 		*defobj_out = defobj;
 	return def;

Reply via email to