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 Instead of using a function to resolve sym...
details: https://anonhg.NetBSD.org/src/rev/a1ce52ee0c9c
branches: trunk
changeset: 349232:a1ce52ee0c9c
user: christos <christos%NetBSD.org@localhost>
date: Thu Dec 01 14:29:15 2016 +0000
description:
Instead of using a function to resolve symbols that should be supplied by
the dynamic linker itself, use a version script that exposes them. From joerg@
diffstat:
libexec/ld.elf_so/Makefile | 3 +-
libexec/ld.elf_so/rtld.c | 10 +++-----
libexec/ld.elf_so/symbol.c | 47 +++---------------------------------------
libexec/ld.elf_so/symbols.map | 26 +++++++++++++++++++++++
4 files changed, 36 insertions(+), 50 deletions(-)
diffs (162 lines):
diff -r eba529ab8d7b -r a1ce52ee0c9c libexec/ld.elf_so/Makefile
--- a/libexec/ld.elf_so/Makefile Thu Dec 01 09:04:37 2016 +0000
+++ b/libexec/ld.elf_so/Makefile Thu Dec 01 14:29:15 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.135 2016/10/07 19:10:03 christos Exp $
+# $NetBSD: Makefile,v 1.136 2016/12/01 14:29:15 christos Exp $
#
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
@@ -124,6 +124,7 @@
COPTS.rtld.c+= -Wno-stack-protector
COPTS.symbol.c+=-Wno-stack-protector
+LDADD+= -Wl,--version-script=${.CURDIR}/symbols.map
LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
.if ${MKPICLIB} != "no"
LDADD+= -lc_pic
diff -r eba529ab8d7b -r a1ce52ee0c9c libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c Thu Dec 01 09:04:37 2016 +0000
+++ b/libexec/ld.elf_so/rtld.c Thu Dec 01 14:29:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.c,v 1.180 2016/11/30 20:25:23 christos Exp $ */
+/* $NetBSD: rtld.c,v 1.181 2016/12/01 14:29:15 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.180 2016/11/30 20:25:23 christos Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.181 2016/12/01 14:29:15 christos Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -1138,14 +1138,12 @@
* Search the dynamic linker itself, and possibly
* resolve the symbol from there if it is not defined
* already or weak. This is how the application links
- * to dynamic linker services such as dlopen. Only the
- * values listed in the "_rtld_exports" array can be
- * resolved from the dynamic linker.
+ * to dynamic linker services such as dlopen.
*/
if (!def || ELF_ST_BIND(def->st_info) == STB_WEAK) {
const Elf_Sym *symp = _rtld_symlook_obj(name,
hash, &_rtld_objself, flags, ventry);
- if (symp != NULL && _rtld_is_exported(symp)) {
+ if (symp != NULL) {
def = symp;
defobj = &_rtld_objself;
}
diff -r eba529ab8d7b -r a1ce52ee0c9c libexec/ld.elf_so/symbol.c
--- a/libexec/ld.elf_so/symbol.c Thu Dec 01 09:04:37 2016 +0000
+++ b/libexec/ld.elf_so/symbol.c Thu Dec 01 14:29:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: symbol.c,v 1.66 2016/11/30 19:43:32 christos Exp $ */
+/* $NetBSD: symbol.c,v 1.67 2016/12/01 14:29:15 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: symbol.c,v 1.66 2016/11/30 19:43:32 christos Exp $");
+__RCSID("$NetBSD: symbol.c,v 1.67 2016/12/01 14:29:15 christos Exp $");
#endif /* not lint */
#include <err.h>
@@ -80,43 +80,6 @@
return false;
}
-bool
-_rtld_is_exported(const Elf_Sym *def)
-{
- static const fptr_t _rtld_exports[] = {
- (fptr_t)dlopen,
- (fptr_t)dlclose,
- (fptr_t)dlsym,
- (fptr_t)dlvsym,
- (fptr_t)dlerror,
- (fptr_t)dladdr,
- (fptr_t)dlinfo,
- (fptr_t)dl_iterate_phdr,
- (fptr_t)_dlauxinfo,
-#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
- (fptr_t)_rtld_tls_allocate,
- (fptr_t)_rtld_tls_free,
- (fptr_t)__tls_get_addr,
-#ifdef __i386__
- (fptr_t)___tls_get_addr,
-#endif
-#endif
-#if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
- (fptr_t)__gnu_Unwind_Find_exidx, /* for gcc EHABI */
-#endif
- NULL
- };
- int i;
- fptr_t value;
-
- value = (fptr_t)(_rtld_objself.relocbase + def->st_value);
- for (i = 0; _rtld_exports[i] != NULL; i++) {
- if (value == _rtld_exports[i])
- return true;
- }
- return false;
-}
-
/*
* Hash function for symbol table lookup. Don't even think about changing
* this. It is specified by the System V ABI.
@@ -565,15 +528,13 @@
/*
* Search the dynamic linker itself, and possibly resolve the
* symbol from there. This is how the application links to
- * dynamic linker services such as dlopen. Only the values listed
- * in the "_rtld_exports" array can be resolved from the dynamic
- * linker.
+ * dynamic linker services such as dlopen.
*/
if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
rdbg(("Search the dynamic linker itself."));
symp = _rtld_symlook_obj(name, hash, &_rtld_objself, flags,
ventry);
- if (symp != NULL && _rtld_is_exported(symp)) {
+ if (symp != NULL) {
def = symp;
defobj = &_rtld_objself;
}
diff -r eba529ab8d7b -r a1ce52ee0c9c libexec/ld.elf_so/symbols.map
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/ld.elf_so/symbols.map Thu Dec 01 14:29:15 2016 +0000
@@ -0,0 +1,26 @@
+{
+ global:
+ dlopen;
+ __dlopen;
+ dlclose;
+ __dlclose;
+ dlsym;
+ __dlsym;
+ dlvsym;
+ __dlvsym;
+ dlerror;
+ __dlerror;
+ dladdr;
+ __dladdr;
+ dlinfo;
+ __dlinfo;
+ dl_iterate_phdr;
+ ____dl_iterate_phdr;
+ _dlauxinfo;
+ _rtld_tls_allocate;
+ _rtld_tls_free;
+ __tls_get_addr;
+ ___tls_get_addr;
+ __gnu_Unwind_Find_exidx;
+ local: *;
+};
Home |
Main Index |
Thread Index |
Old Index