mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-21 10:20:06 +00:00
Update.
2002-06-30 Ulrich Drepper <drepper@redhat.com> * elf/dl-lookup.c (add_dependency): It is not necessary to add dependencies if they are created between objects which are created while processing RTLD_NOW for objects loaded as part of the same dlopen call. 2002-06-14 H.J. Lu <hjl@gnu.org> * elf/Makefile (tests): Add circleload1. (modules-names): Add circlemod1, circlemod2, circlemod3, circlemod1a, circlemod2a and circlemod3a. ($(objpfx)circleload1): New target. ($(objpfx)circleload1.out): Likewise. ($(objpfx)circlemod1.so): Likewise. ($(objpfx)circlemod2.so): Likewise. ($(objpfx)circlemod1a.so): Likewise. ($(objpfx)circlemod2a.so): Likewise. * elf/circleload1.c: New file. * elf/circlemod1.c: New file. * elf/circlemod1a.c: New file. * elf/circlemod2.c: New file. * elf/circlemod2a.c: New file. * elf/circlemod3.c: New file. * elf/circlemod3a.c: New file.
This commit is contained in:
parent
95fdc6a0f6
commit
6d78cd000f
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
||||
2002-06-30 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* elf/dl-lookup.c (add_dependency): It is not necessary to add
|
||||
dependencies if they are created between objects which are created
|
||||
while processing RTLD_NOW for objects loaded as part of the same
|
||||
dlopen call.
|
||||
|
||||
2002-06-14 H.J. Lu <hjl@gnu.org>
|
||||
|
||||
* elf/Makefile (tests): Add circleload1.
|
||||
(modules-names): Add circlemod1, circlemod2, circlemod3,
|
||||
circlemod1a, circlemod2a and circlemod3a.
|
||||
($(objpfx)circleload1): New target.
|
||||
($(objpfx)circleload1.out): Likewise.
|
||||
($(objpfx)circlemod1.so): Likewise.
|
||||
($(objpfx)circlemod2.so): Likewise.
|
||||
($(objpfx)circlemod1a.so): Likewise.
|
||||
($(objpfx)circlemod2a.so): Likewise.
|
||||
* elf/circleload1.c: New file.
|
||||
* elf/circlemod1.c: New file.
|
||||
* elf/circlemod1a.c: New file.
|
||||
* elf/circlemod2.c: New file.
|
||||
* elf/circlemod2a.c: New file.
|
||||
* elf/circlemod3.c: New file.
|
||||
* elf/circlemod3a.c: New file.
|
||||
|
||||
2002-06-18 Amos Waterland <apw@us.ibm.com>
|
||||
|
||||
* sysdeps/pthread/aio_cancel.c (aio_cancel): Add check for invalid
|
||||
|
16
elf/Makefile
16
elf/Makefile
@ -119,7 +119,8 @@ tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
|
||||
$(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
|
||||
neededtest3 neededtest4 unload2 lateglobal initfirst global \
|
||||
restest2 next dblload dblunload reldep5 reldep6 reldep7 tst-tls1 \
|
||||
tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8
|
||||
tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
|
||||
circleload1
|
||||
test-srcs = tst-pathopt
|
||||
tests-vis-yes = vismain
|
||||
tests-nodelete-yes = nodelete
|
||||
@ -138,7 +139,9 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
|
||||
dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
|
||||
reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
|
||||
reldep7mod1 reldep7mod2 \
|
||||
tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4
|
||||
tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4 \
|
||||
circlemod1 circlemod1a circlemod2 circlemod2a \
|
||||
circlemod3 circlemod3a
|
||||
modules-vis-yes = vismod1 vismod2 vismod3
|
||||
modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
|
||||
modules-nodlopen-yes = nodlopenmod nodlopenmod2
|
||||
@ -361,6 +364,15 @@ endif
|
||||
$(objpfx)constload1: $(libdl)
|
||||
$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
|
||||
|
||||
$(objpfx)circleload1: $(libdl)
|
||||
$(objpfx)circleload1.out: $(objpfx)circlemod1.so \
|
||||
$(objpfx)circlemod1a.so
|
||||
|
||||
$(objpfx)circlemod1.so: $(objpfx)circlemod2.so
|
||||
$(objpfx)circlemod2.so: $(objpfx)circlemod3.so
|
||||
$(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
|
||||
$(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
|
||||
|
||||
$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
|
||||
|
||||
$(objpfx)order.out: $(objpfx)order
|
||||
|
146
elf/circleload1.c
Normal file
146
elf/circleload1.c
Normal file
@ -0,0 +1,146 @@
|
||||
#include <dlfcn.h>
|
||||
#include <libintl.h>
|
||||
#include <link.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int
|
||||
check_loaded_objects (const char **loaded)
|
||||
{
|
||||
struct link_map *lm;
|
||||
int n;
|
||||
int *found = NULL;
|
||||
int errors = 0;
|
||||
|
||||
for (n = 0; loaded[n]; n++)
|
||||
/* NOTHING */;
|
||||
|
||||
if (n)
|
||||
{
|
||||
found = (int *) alloca (sizeof (int) * n);
|
||||
memset (found, 0, sizeof (int) * n);
|
||||
}
|
||||
|
||||
printf(" Name\n");
|
||||
printf(" --------------------------------------------------------\n");
|
||||
for (lm = _r_debug.r_map; lm; lm = lm->l_next)
|
||||
{
|
||||
if (lm->l_name && lm->l_name[0])
|
||||
printf(" %s, count = %d\n", lm->l_name, (int) lm->l_opencount);
|
||||
if (lm->l_type == lt_loaded && lm->l_name)
|
||||
{
|
||||
int match = 0;
|
||||
for (n = 0; loaded[n] != NULL; n++)
|
||||
{
|
||||
if (strcmp (basename (loaded[n]), basename (lm->l_name)) == 0)
|
||||
{
|
||||
found[n] = 1;
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match == 0)
|
||||
{
|
||||
++errors;
|
||||
printf ("ERRORS: %s is not unloaded\n", lm->l_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (n = 0; loaded[n] != NULL; n++)
|
||||
{
|
||||
if (found[n] == 0)
|
||||
{
|
||||
++errors;
|
||||
printf ("ERRORS: %s is not loaded\n", loaded[n]);
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
static int
|
||||
load_dso (const char **loading, int undef, int flag)
|
||||
{
|
||||
void *obj;
|
||||
const char *loaded[] = { NULL, NULL, NULL, NULL };
|
||||
int errors = 0;
|
||||
const char *errstring;
|
||||
|
||||
printf ("\nThis is what is in memory now:\n");
|
||||
errors += check_loaded_objects (loaded);
|
||||
|
||||
printf ("Loading shared object %s: %s\n", loading [0],
|
||||
flag == RTLD_LAZY ? "RTLD_LAZY" : "RTLD_NOW");
|
||||
obj = dlopen (loading [0], flag);
|
||||
if (obj == NULL)
|
||||
{
|
||||
if (flag == RTLD_LAZY)
|
||||
{
|
||||
++errors;
|
||||
printf ("ERRORS: dlopen shouldn't fail for RTLD_LAZY\n");
|
||||
}
|
||||
|
||||
errstring = dlerror ();
|
||||
if (strstr (errstring, "undefined symbol") == 0
|
||||
|| strstr (errstring, "circlemod2_undefined") == 0)
|
||||
{
|
||||
++errors;
|
||||
printf ("ERRORS: dlopen: `%s': Invalid error string\n",
|
||||
errstring);
|
||||
}
|
||||
else
|
||||
printf ("dlopen: %s\n", errstring);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (undef && flag == RTLD_NOW)
|
||||
{
|
||||
++errors;
|
||||
printf ("ERRORS: dlopen shouldn't work for RTLD_NOW\n");
|
||||
}
|
||||
|
||||
loaded[0] = loading [0];
|
||||
loaded[1] = loading [1];
|
||||
loaded[2] = loading [2];
|
||||
}
|
||||
errors += check_loaded_objects (loaded);
|
||||
|
||||
if (obj)
|
||||
{
|
||||
printf ("UnLoading shared object %s\n", loading [0]);
|
||||
dlclose (obj);
|
||||
loaded[0] = NULL;
|
||||
loaded[1] = NULL;
|
||||
loaded[2] = NULL;
|
||||
errors += check_loaded_objects (loaded);
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int errors = 0;
|
||||
const char *loading[3];
|
||||
|
||||
loading [0] = "circlemod1a.so";
|
||||
loading [1] = "circlemod2a.so";
|
||||
loading [2] = "circlemod3a.so";
|
||||
errors += load_dso (loading, 0, RTLD_LAZY);
|
||||
errors += load_dso (loading, 0, RTLD_NOW);
|
||||
|
||||
loading [0] = "circlemod1.so";
|
||||
loading [1] = "circlemod2.so";
|
||||
loading [2] = "circlemod3.so";
|
||||
errors += load_dso (loading, 1, RTLD_LAZY);
|
||||
errors += load_dso (loading, 1, RTLD_NOW);
|
||||
|
||||
if (errors != 0)
|
||||
printf ("%d errors found\n", errors);
|
||||
|
||||
return errors;
|
||||
}
|
7
elf/circlemod1.c
Normal file
7
elf/circlemod1.c
Normal file
@ -0,0 +1,7 @@
|
||||
extern void circlemod2 (void);
|
||||
|
||||
void
|
||||
circlemod1 (void)
|
||||
{
|
||||
circlemod2 ();
|
||||
}
|
1
elf/circlemod1a.c
Normal file
1
elf/circlemod1a.c
Normal file
@ -0,0 +1 @@
|
||||
#include "circlemod1.c"
|
9
elf/circlemod2.c
Normal file
9
elf/circlemod2.c
Normal file
@ -0,0 +1,9 @@
|
||||
extern void circlemod2_undefined (void);
|
||||
extern void circlemod3 (void);
|
||||
|
||||
void
|
||||
circlemod2 (void)
|
||||
{
|
||||
circlemod2_undefined ();
|
||||
circlemod3 ();
|
||||
}
|
7
elf/circlemod2a.c
Normal file
7
elf/circlemod2a.c
Normal file
@ -0,0 +1,7 @@
|
||||
extern void circlemod3 (void);
|
||||
|
||||
void
|
||||
circlemod2 (void)
|
||||
{
|
||||
circlemod3 ();
|
||||
}
|
9
elf/circlemod3.c
Normal file
9
elf/circlemod3.c
Normal file
@ -0,0 +1,9 @@
|
||||
extern void circlemod1 (void);
|
||||
extern void circlemod2 (void);
|
||||
|
||||
void
|
||||
circlemod3 (void)
|
||||
{
|
||||
circlemod1 ();
|
||||
circlemod2 ();
|
||||
}
|
1
elf/circlemod3a.c
Normal file
1
elf/circlemod3a.c
Normal file
@ -0,0 +1 @@
|
||||
#include "circlemod3.c"
|
@ -94,6 +94,11 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
|
||||
if (undef_map == map)
|
||||
return 0;
|
||||
|
||||
/* Don't create cross-reference between modules which are
|
||||
dynamically loaded by the same dlopen() call. */
|
||||
if (undef_map->l_opencount == 0 && map->l_opencount == 0)
|
||||
return 0;
|
||||
|
||||
/* Make sure nobody can unload the object while we are at it. */
|
||||
__libc_lock_lock_recursive (GL(dl_load_lock));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user