diff options
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/library_subr.c | 6 | ||||
-rw-r--r-- | libexec/ld.so/loader.c | 9 | ||||
-rw-r--r-- | libexec/ld.so/resolve.c | 48 |
3 files changed, 26 insertions, 37 deletions
diff --git a/libexec/ld.so/library_subr.c b/libexec/ld.so/library_subr.c index 44227c75f8f..4c5b4944233 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.8 2005/09/17 04:15:23 drahn Exp $ */ +/* $OpenBSD: library_subr.c,v 1.9 2005/09/19 02:31:04 drahn Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -383,6 +383,10 @@ _dl_unload_dlopen(void) struct dep_node *node; TAILQ_FOREACH_REVERSE(node, &_dlopened_child_list, dlochld, next_sib) { + /* dont dlclose the main program */ + if (node->data == _dl_objects) + continue; + _dl_notify_unload_shlib(node->data); _dl_run_all_dtors(); if (_dl_exiting == 0) diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 55049a35744..ef92ae03fb6 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.87 2005/09/16 23:19:41 drahn Exp $ */ +/* $OpenBSD: loader.c,v 1.88 2005/09/19 02:31:04 drahn Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -322,11 +322,18 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data) } phdp++; } + exe_obj->obj_flags = RTLD_GLOBAL; exe_obj->load_object = exe_obj; TAILQ_INIT(&exe_obj->dload_list); n = _dl_malloc(sizeof *n); if (n == NULL) + _dl_exit(5); + n->data = exe_obj; + TAILQ_INSERT_TAIL(&_dlopened_child_list, n, next_sib); + + n = _dl_malloc(sizeof *n); + if (n == NULL) _dl_exit(9); n->data = exe_obj; TAILQ_INSERT_TAIL(&exe_obj->dload_list, n, next_sib); diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c index 474f011e3ac..62dd3bffe4b 100644 --- a/libexec/ld.so/resolve.c +++ b/libexec/ld.so/resolve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.c,v 1.29 2005/09/16 23:41:05 drahn Exp $ */ +/* $OpenBSD: resolve.c,v 1.30 2005/09/19 02:31:04 drahn Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -286,26 +286,6 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref, object = req_obj; found = 1; } - } else if ((flags & SYM_SEARCH_SELF) || (flags & SYM_SEARCH_NEXT)) { - /* search after req_obj in the objects's load group */ - int skip = 1; - - TAILQ_FOREACH(n, &req_obj->load_object->dload_list, next_sib) { - - if (n->data == req_obj && skip == 1) { - skip = 0; - if (flags & SYM_SEARCH_NEXT) - continue; - } - if (skip == 1) - continue; - if (_dl_find_symbol_obj(n->data, name, h, flags, ref, - &weak_sym, &weak_object)) { - object = n->data; - found = 1; - break; - } - } } else if (flags & SYM_DLSYM) { if (_dl_find_symbol_obj(req_obj, name, h, flags, ref, &weak_sym, &weak_object)) { @@ -332,21 +312,11 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref, } } } else { - /* search main program and it's libs */ - TAILQ_FOREACH(n, &_dl_objects->dload_list, next_sib) { - if ((flags & SYM_SEARCH_OTHER) && - (n->data == req_obj)) { - continue; - } - - if (_dl_find_symbol_obj(n->data, name, h, flags, - ref, &weak_sym, &weak_object)) { - object = n->data; - found = 1; - goto found; - } - } + int skip = 0; + if ((flags & SYM_SEARCH_SELF) || (flags & SYM_SEARCH_NEXT)) + skip = 1; + /* * search dlopened objects: global or req_obj == dlopened_obj * and and it's children @@ -357,6 +327,14 @@ _dl_find_symbol(const char *name, const Elf_Sym **ref, continue; TAILQ_FOREACH(m, &n->data->dload_list, next_sib) { + if (skip == 1) { + if (m->data == req_obj) { + skip = 0; + if (flags & SYM_SEARCH_NEXT) + continue; + } else + continue; + } if ((flags & SYM_SEARCH_OTHER) && (m->data == req_obj)) continue; |