From 42c4f32a44c76d1f4e2b744bf80f495dc36caa87 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 24 Oct 2000 07:36:55 +0000 Subject: Update. 2000-10-24 Ulrich Drepper Complete revamp of the reference counter handling. * include/link.h (struct link_map): Add l_idx field. * elf/dl-close.c: Handle decrementing of reference counters more correctly. If necessary decrement reference counters of dependencies of dependencies. * elf/dl-lookup.c (add_dependency): Only increment reference counter of the object itself and not also its dependencies. * elf/dl-open.c: Increment reference counters here. * elf/dl-deps.c: Remove reference counter handling here. * elf/dl-load.c: Likewise. * elf/rtld.c: Adjust for _dl_map_deps not handling reference counters. * elf/loadtest.c: Print loaded objects at the beginning. --- elf/rtld.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'elf/rtld.c') diff --git a/elf/rtld.c b/elf/rtld.c index ea5d7b5a3d..c44506acc4 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -550,7 +550,6 @@ of this helper program; chances are you did not intend to run this program.\n\ _dl_loaded->l_phdr = phdr; _dl_loaded->l_phnum = phent; _dl_loaded->l_entry = *user_entry; - _dl_loaded->l_opencount = 1; /* At this point we are in a bit of trouble. We would have to fill in the values for l_dev and l_ino. But in general we @@ -707,7 +706,7 @@ of this helper program; chances are you did not intend to run this program.\n\ { struct link_map *new_map = _dl_map_object (_dl_loaded, p, 1, lt_library, 0, 0); - if (new_map->l_opencount == 1) + if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; } @@ -775,7 +774,7 @@ of this helper program; chances are you did not intend to run this program.\n\ { struct link_map *new_map = _dl_map_object (_dl_loaded, p, 1, lt_library, 0, 0); - if (new_map->l_opencount == 1) + if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; } @@ -786,7 +785,7 @@ of this helper program; chances are you did not intend to run this program.\n\ char *p = strndupa (problem, file_size - (problem - file)); struct link_map *new_map = _dl_map_object (_dl_loaded, p, 1, lt_library, 0, 0); - if (new_map->l_opencount == 1) + if (++new_map->l_opencount == 1) /* It is no duplicate. */ ++npreloads; } @@ -823,9 +822,14 @@ of this helper program; chances are you did not intend to run this program.\n\ HP_TIMING_DIFF (diff, start, stop); HP_TIMING_ACCUM_NT (load_time, diff); - /* Mark all objects as being in the global scope. */ + /* Mark all objects as being in the global scope and set the open + counter. */ for (i = _dl_loaded->l_searchlist.r_nlist; i > 0; ) - _dl_loaded->l_searchlist.r_list[--i]->l_global = 1; + { + --i; + _dl_loaded->l_searchlist.r_list[i]->l_global = 1; + ++_dl_loaded->l_searchlist.r_list[i]->l_opencount; + } #ifndef MAP_ANON /* We are done mapping things, so close the zero-fill descriptor. */ -- cgit v1.2.3