From c4bb124a75b23d1a82cee232005dc7e8c43a4276 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 8 Sep 2001 16:27:08 +0000 Subject: Update. 2001-09-08 Ulrich Drepper * elf/dl-close.c (_dl_close): If object has no r_list (i.e., wasn't loaded directly) determine length if l_initfini list by iterating over its elements. Minor optimizations. * elf/dl-deps.c (_dl_map_object_deps): Always add own map to l_initfini for dependency objects. If object was already loaded check whether any of the dependencies is already on the relocation dependency list. If yes, remove the latter. Minor optimizations. * elf/dl-lookup.c (add_dependency): Add check for self reference of maps here. Search l_initfini list only if the object was loaded directly and not only as a dependency. (_dl_lookup_symbol): Add relocation dependency also if object is not in global scope. Remove test for self-reference here. (_dl_lookup_versioned_symbol): Likewise. * elf/dl-object (_dl_new_object): Cleanup. Initialize dont_free element of first name record. * elf/loadtest.c: Add some more test to recognize early if an object wasn't unloaded. * elf/Makefile: Add rules to build and run reldep5. * elf/reldep5.c: New file. * elf/reldepmod5.c: New file. * elf/reldepmod6.c: New file. * elf/reldep2.c: Fix typo. * elf/dl-object.c (_dl_new_object): Initialize l_scope and l_scope_max. --- elf/reldep5.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 elf/reldep5.c (limited to 'elf/reldep5.c') diff --git a/elf/reldep5.c b/elf/reldep5.c new file mode 100644 index 0000000000..982265f251 --- /dev/null +++ b/elf/reldep5.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +int +main (void) +{ + void *h1; + void *h2; + int (*fp) (void); + int *vp; + + mtrace (); + + /* Open the two objects. */ + h1 = dlopen ("reldepmod5.so", RTLD_LAZY); + if (h1 == NULL) + { + printf ("cannot open reldepmod5.so: %s\n", dlerror ()); + exit (1); + } + h2 = dlopen ("reldepmod6.so", RTLD_LAZY); + if (h2 == NULL) + { + printf ("cannot open reldepmod6.so: %s\n", dlerror ()); + exit (1); + } + + /* Get the address of the variable in reldepmod1.so. */ + fp = dlsym (h2, "bar"); + if (fp == NULL) + { + printf ("cannot get address of \"bar\": %s\n", dlerror ()); + exit (1); + } + + /* Call the function. */ + puts ("calling fp for the first time"); + if (fp () != 0) + { + puts ("function \"call_me\" returned wrong result"); + exit (1); + } + + /* Now close the first object. It must still be around since we have + an implicit dependency. */ + if (dlclose (h1) != 0) + { + printf ("closing h1 failed: %s\n", dlerror ()); + exit (1); + } + + /* Calling the function must still work. */ + puts ("calling fp for the second time"); + if (fp () != 0) + { + puts ("function \"call_me\" the second time returned wrong result"); + exit (1); + } + puts ("second call suceeded as well"); + + /* Close the second object, we are done. */ + if (dlclose (h2) != 0) + { + printf ("closing h2 failed: %s\n", dlerror ()); + exit (1); + } + + return 0; +} -- cgit v1.2.3