Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Use alloca(3) instead of local xmalloc for...
details: https://anonhg.NetBSD.org/src/rev/4e9683faf174
branches: trunk
changeset: 753156:4e9683faf174
user: roy <roy%NetBSD.org@localhost>
date: Thu Mar 18 22:17:55 2010 +0000
description:
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.
diffstat:
libexec/ld.elf_so/Makefile | 6 +++++-
libexec/ld.elf_so/rtld.c | 8 ++------
libexec/ld.elf_so/rtld.h | 13 +++++++------
libexec/ld.elf_so/symbol.c | 6 ++----
4 files changed, 16 insertions(+), 17 deletions(-)
diffs (114 lines):
diff -r 75e31281f24a -r 4e9683faf174 libexec/ld.elf_so/Makefile
--- a/libexec/ld.elf_so/Makefile Thu Mar 18 22:11:48 2010 +0000
+++ b/libexec/ld.elf_so/Makefile Thu Mar 18 22:17:55 2010 +0000
@@ -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}
diff -r 75e31281f24a -r 4e9683faf174 libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c Thu Mar 18 22:11:48 2010 +0000
+++ b/libexec/ld.elf_so/rtld.c Thu Mar 18 22:17:55 2010 +0000
@@ -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;
}
diff -r 75e31281f24a -r 4e9683faf174 libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h Thu Mar 18 22:11:48 2010 +0000
+++ b/libexec/ld.elf_so/rtld.h Thu Mar 18 22:17:55 2010 +0000
@@ -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 */
diff -r 75e31281f24a -r 4e9683faf174 libexec/ld.elf_so/symbol.c
--- a/libexec/ld.elf_so/symbol.c Thu Mar 18 22:11:48 2010 +0000
+++ b/libexec/ld.elf_so/symbol.c Thu Mar 18 22:17:55 2010 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index