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 Emulate the standard symbol search order i...
details: https://anonhg.NetBSD.org/src/rev/8dd89f25ef55
branches: trunk
changeset: 819356:8dd89f25ef55
user: christos <christos%NetBSD.org@localhost>
date: Wed Nov 30 19:43:32 2016 +0000
description:
Emulate the standard symbol search order in dlsym() i.e. resolve weak or
not found symbols that are in the dynamic linker list of exported symbols
from the dynamic linker itself.
diffstat:
libexec/ld.elf_so/rtld.c | 19 +++++++++++++++++--
libexec/ld.elf_so/rtld.h | 3 ++-
libexec/ld.elf_so/symbol.c | 6 +++---
3 files changed, 22 insertions(+), 6 deletions(-)
diffs (84 lines):
diff -r 02ea3a14f003 -r 8dd89f25ef55 libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c Wed Nov 30 17:23:16 2016 +0000
+++ b/libexec/ld.elf_so/rtld.c Wed Nov 30 19:43:32 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.c,v 1.178 2016/05/24 20:32:33 christos Exp $ */
+/* $NetBSD: rtld.c,v 1.179 2016/11/30 19:43:32 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.178 2016/05/24 20:32:33 christos Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.179 2016/11/30 19:43:32 christos Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -1134,6 +1134,21 @@
break;
}
}
+ /*
+ * 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.
+ */
+ 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)) {
+ def = symp;
+ defobj = &_rtld_objself;
+ }
+ }
break;
case (intptr_t)RTLD_DEFAULT:
diff -r 02ea3a14f003 -r 8dd89f25ef55 libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h Wed Nov 30 17:23:16 2016 +0000
+++ b/libexec/ld.elf_so/rtld.h Wed Nov 30 19:43:32 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.h,v 1.125 2016/06/14 13:06:41 christos Exp $ */
+/* $NetBSD: rtld.h,v 1.126 2016/11/30 19:43:32 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -416,6 +416,7 @@
Obj_Entry *_rtld_load_library(const char *, const Obj_Entry *, int);
/* symbol.c */
+bool _rtld_is_exported(const Elf_Sym *);
unsigned long _rtld_elf_hash(const char *);
const Elf_Sym *_rtld_symlook_obj(const char *, unsigned long,
const Obj_Entry *, u_int, const Ver_Entry *);
diff -r 02ea3a14f003 -r 8dd89f25ef55 libexec/ld.elf_so/symbol.c
--- a/libexec/ld.elf_so/symbol.c Wed Nov 30 17:23:16 2016 +0000
+++ b/libexec/ld.elf_so/symbol.c Wed Nov 30 19:43:32 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: symbol.c,v 1.65 2014/08/10 23:35:26 matt Exp $ */
+/* $NetBSD: symbol.c,v 1.66 2016/11/30 19:43:32 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: symbol.c,v 1.65 2014/08/10 23:35:26 matt Exp $");
+__RCSID("$NetBSD: symbol.c,v 1.66 2016/11/30 19:43:32 christos Exp $");
#endif /* not lint */
#include <err.h>
@@ -80,7 +80,7 @@
return false;
}
-static bool
+bool
_rtld_is_exported(const Elf_Sym *def)
{
static const fptr_t _rtld_exports[] = {
Home |
Main Index |
Thread Index |
Old Index