Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/lib/libc/dlfcn Pull up revision 1.4 (requested by skrll...
details: https://anonhg.NetBSD.org/src/rev/c58d4e6ba69a
branches: netbsd-1-6
changeset: 531364:c58d4e6ba69a
user: tron <tron%NetBSD.org@localhost>
date: Fri May 28 09:01:18 2004 +0000
description:
Pull up revision 1.4 (requested by skrll in ticket #1702):
Resolve dlsym(3) and friends directly so that dlsym(RTLD_NEXT,...) works.
Previously dlsym resolved to the version in crt0.o or libc which would
mean that the caller's shared object couldn't be determined correctly
using __builtin_return_address(0).
Mainly from FreeBSD, but adapted by me. Benefits of this solutions are:
- backward comptibility maintained
- existing broken binaries are fixed with a new ld.elf_so
- __mainprog_obj can be removed from crt0.o
- we do the same thing as FreeBSD
Fixes PR 22067.
OKed by Jason and Christos.
diffstat:
lib/libc/dlfcn/dlfcn_elf.c | 61 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 8 deletions(-)
diffs (86 lines):
diff -r 7888b1db6960 -r c58d4e6ba69a lib/libc/dlfcn/dlfcn_elf.c
--- a/lib/libc/dlfcn/dlfcn_elf.c Fri May 28 09:01:13 2004 +0000
+++ b/lib/libc/dlfcn/dlfcn_elf.c Fri May 28 09:01:18 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dlfcn_elf.c,v 1.2.4.1 2004/05/28 08:59:36 tron Exp $ */
+/* $NetBSD: dlfcn_elf.c,v 1.2.4.2 2004/05/28 09:01:18 tron Exp $ */
/*
* Copyright (c) 2000 Takuya SHIOZAKI
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dlfcn_elf.c,v 1.2.4.1 2004/05/28 08:59:36 tron Exp $");
+__RCSID("$NetBSD: dlfcn_elf.c,v 1.2.4.2 2004/05/28 09:01:18 tron Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -35,11 +35,6 @@
#define ELFSIZE ARCH_ELFSIZE
#include "rtld.h"
-#ifdef __weak_extern
-__weak_extern(__mainprog_obj)
-#endif
-extern const Obj_Entry *__mainprog_obj;
-
#ifdef __weak_alias
__weak_alias(dlopen,__dlopen)
__weak_alias(dlclose,__dlclose)
@@ -48,4 +43,54 @@
__weak_alias(dladdr,__dladdr)
#endif
-#include <dlfcn_stubs.c>
+/*
+ * For ELF, the dynamic linker directly resolves references to its
+ * services to functions inside the dynamic linker itself. These
+ * weak-symbol stubs are necessary so that "ld" won't complain about
+ * undefined symbols. The stubs are executed only when the program is
+ * linked statically, or when a given service isn't implemented in the
+ * dynamic linker. They must return an error if called, and they must
+ * be weak symbols so that the dynamic linker can override them.
+ */
+
+static char dlfcn_error[] = "Service unavailable";
+
+/*ARGSUSED*/
+void *
+dlopen(const char *name, int mode)
+{
+
+ return NULL;
+}
+
+/*ARGSUSED*/
+int
+dlclose(void *fd)
+{
+
+ return -1;
+}
+
+/*ARGSUSED*/
+void *
+dlsym(void *handle, const char *name)
+{
+
+ return NULL;
+}
+
+/*ARGSUSED*/
+__aconst char *
+dlerror()
+{
+
+ return dlfcn_error;
+}
+
+/*ARGSUSED*/
+int
+dladdr(const void *addr, Dl_info *dli)
+{
+
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index