summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2005-05-23 19:22:12 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2005-05-23 19:22:12 +0000
commit629d7ba9c6d9460e3ace845d7c0455aa9c7eeba0 (patch)
treecc9b3c9751665a386ad47c8b853aa2fca2ec93f7 /libexec
parent0cc57afd9f0fb72873642d528cec2016f9a0953e (diff)
fixes for dlclose, ok kettenis@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ld.so/dlfcn.c31
-rw-r--r--libexec/ld.so/library.c9
-rw-r--r--libexec/ld.so/library_mquery.c11
-rw-r--r--libexec/ld.so/library_subr.c12
4 files changed, 17 insertions, 46 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index 1df2329e36b..72c7400ffb8 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.47 2005/05/10 03:36:07 drahn Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.48 2005/05/23 19:22:11 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -41,9 +41,8 @@
int _dl_errno;
int _dl_real_close(void *handle);
-void _dl_unload_deps(elf_object_t *object);
void (*_dl_thread_fnc)(int) = NULL;
-elf_object_t *obj_from_addr(const void *addr);
+static elf_object_t *obj_from_addr(const void *addr);
void *
dlopen(const char *libname, int flags)
@@ -246,35 +245,13 @@ _dl_real_close(void *handle)
return (1);
}
- if (object->refcount == 1) {
- if (dynobj->dep_next)
- _dl_unload_deps(dynobj);
- }
-
_dl_unlink_dlopen(object);
+ _dl_notify_unload_shlib(object);
+ _dl_run_all_dtors();
_dl_unload_shlib(object);
return (0);
}
-/*
- * Scan through the shadow dep list and 'unload' every library
- * we depend upon. Shadow objects are removed when removing ourself.
- */
-void
-_dl_unload_deps(elf_object_t *object)
-{
- elf_object_t *depobj;
-
- depobj = object->dep_next;
- while (depobj) {
- if (depobj->next->refcount == 1) { /* This object will go away */
- if (depobj->next->dep_next)
- _dl_unload_deps(depobj->next);
- _dl_unload_shlib(depobj->next);
- }
- depobj = depobj->dep_next;
- }
-}
/*
* Return a character string describing the last dl... error occurred.
diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c
index b1b3895b91d..37b5eed57f0 100644
--- a/libexec/ld.so/library.c
+++ b/libexec/ld.so/library.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library.c,v 1.39 2005/05/10 03:36:07 drahn Exp $ */
+/* $OpenBSD: library.c,v 1.40 2005/05/23 19:22:11 drahn Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -55,13 +55,6 @@ _dl_load_list_free(struct load_list *load_list)
}
void
-_dl_notify_unload_shlib(elf_object_t *object)
-{
- if (--object->refcount == 0) {
- _dl_run_dtors(object);
- }
-}
-void
_dl_unload_shlib(elf_object_t *object)
{
if (object->refcount == 0) {
diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c
index 300978e4372..e01361df8e1 100644
--- a/libexec/ld.so/library_mquery.c
+++ b/libexec/ld.so/library_mquery.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library_mquery.c,v 1.19 2005/05/10 03:36:07 drahn Exp $ */
+/* $OpenBSD: library_mquery.c,v 1.20 2005/05/23 19:22:11 drahn Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -58,15 +58,6 @@ _dl_load_list_free(struct load_list *load_list)
}
}
-void
-_dl_notify_unload_shlib(elf_object_t *object)
-{
- struct dep_node *n;
-
- if (--object->refcount == 0)
- for (n = object->first_child; n; n = n->next_sibling)
- _dl_notify_unload_shlib(n->data);
-}
void
_dl_unload_shlib(elf_object_t *object)
diff --git a/libexec/ld.so/library_subr.c b/libexec/ld.so/library_subr.c
index 07f69f9e24b..c2e7d8f8e81 100644
--- a/libexec/ld.so/library_subr.c
+++ b/libexec/ld.so/library_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library_subr.c,v 1.4 2005/05/10 03:36:07 drahn Exp $ */
+/* $OpenBSD: library_subr.c,v 1.5 2005/05/23 19:22:11 drahn Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -388,6 +388,16 @@ _dl_unlink_dlopen(elf_object_t *dep)
}
void
+_dl_notify_unload_shlib(elf_object_t *object)
+{
+ struct dep_node *n;
+
+ if (--object->refcount == 0)
+ for (n = object->first_child; n; n = n->next_sibling)
+ _dl_notify_unload_shlib(n->data);
+}
+
+void
_dl_unload_dlopen(void)
{
if (_dlopened_first_child != NULL)