mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-16 18:10:11 +00:00
d785c36692
2000-10-21 Ulrich Drepper <drepper@redhat.com> * elf/dl-open.c (add_to_global): New function. Split out from dl_open_worker. (dl_open_worker): Call add_to_global not only for new objects, also for previously loaded objects when (mode & RTLD_GLOBAL) and the object was not yet in the global scope. * elf/Makefile: Add rules to build and run lateglobal. * elf/lateglobal.c: New file. * elf/ltglobmod1.c: New file. * elf/ltglobmod2.c: New file.
48 lines
848 B
C
48 lines
848 B
C
#include <dlfcn.h>
|
|
#include <mcheck.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
void *h[2];
|
|
int fail;
|
|
int (*fp) (void);
|
|
|
|
mtrace ();
|
|
|
|
h[0] = dlopen ("ltglobmod1.so", RTLD_LAZY);
|
|
if (h == NULL)
|
|
{
|
|
printf ("%s: cannot open %s: %s",
|
|
__FUNCTION__, "ltglobmod1.so", dlerror ());
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
h[1] = dlopen ("ltglobmod2.so", RTLD_LAZY);
|
|
if (h == NULL)
|
|
{
|
|
printf ("%s: cannot open %s: %s",
|
|
__FUNCTION__, "ltglobmod2.so", dlerror ());
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
puts ("loaded \"ltglobmod1.so\" without RTLD_GLOBAL");
|
|
|
|
fp = dlsym (h[1], "foo");
|
|
if (fp == NULL)
|
|
{
|
|
printf ("cannot get address of `foo': %s", dlerror ());
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
fail = fp ();
|
|
|
|
puts ("back in main");
|
|
|
|
dlclose (h[1]);
|
|
dlclose (h[0]);
|
|
|
|
return fail;
|
|
}
|