mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 13:13:43 +08:00
84aafa9199
2001-09-07 Tom Rix <trix@redhat.com> * sysdeps/unix/sysv/aix/sysv_termio.h: New file. 2001-08-26 Tom Rix <trix@redhat.com> * sysdeps/unix/sysv/aix/Makefile (aix-syscalls.o): More linker command line options. * sysdeps/unix/sysv/aix/start.s: New file, rework of start.c * sysdeps/unix/sysv/aix/start.c: Removed. * sysdeps/unix/sysv/aix/start-libc.c: New file. * sysdeps/unix/sysv/aix/init-first.c: New file. * sysdeps/unix/sysv/aix/fcntl.c: Alias __libc_fcntl to __fcntl. 2001-09-08 Ben Collins <bcollins@debian.org> * sysdeps/arm/dl-machine.h: Fix usage of new _dl_signal_error() format. * sysdeps/generic/dl-machine.h: Likewise. * sysdeps/hppa/dl-fptr.c: Likewise. * sysdeps/ia64/dl-fptr.c: Likewise. * sysdeps/mach/hurd/dl-sysdep.c: Likewise. * sysdeps/mips/dl-machine.h: Likewise. * sysdeps/mips/mips64/dl-machine.h: Likewise. * sysdeps/powerpc/dl-machine.c: Likewise. 2001-09-07 Ben Collins <bcollins@debian.org> * sysdeps/sparc/sparc32/dl-machine.h: Fix typo. * sysdeps/hppa/dl-lookupcfg.h: Forward declare struct link_map. * elf/dl-lookup.c (add_dependency): Bump l_opencount of all dependencies if necessary.
102 lines
2.2 KiB
C
102 lines
2.2 KiB
C
#include <dlfcn.h>
|
|
#include <mcheck.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
void *h1;
|
|
void *h2;
|
|
int (*fp) (void);
|
|
int *vp;
|
|
|
|
mtrace ();
|
|
|
|
/* Open the two objects. */
|
|
h1 = dlopen ("reldepmod1.so", RTLD_LAZY | RTLD_GLOBAL);
|
|
if (h1 == NULL)
|
|
{
|
|
printf ("cannot open reldepmod1.so: %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
h2 = dlopen ("reldepmod3.so", RTLD_LAZY);
|
|
if (h2 == NULL)
|
|
{
|
|
printf ("cannot open reldepmod3.so: %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
|
|
/* Get the address of the variable in reldepmod1.so. */
|
|
vp = dlsym (h1, "some_var");
|
|
if (vp == NULL)
|
|
{
|
|
printf ("cannot get address of \"some_var\": %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
|
|
*vp = 42;
|
|
|
|
/* Get the function `call_me' in the second object. This has a
|
|
dependency which is resolved by a definition in reldepmod1.so. */
|
|
fp = dlsym (h2, "call_me");
|
|
if (fp == NULL)
|
|
{
|
|
printf ("cannot get address of \"call_me\": %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
|
|
/* Call the function. */
|
|
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);
|
|
}
|
|
|
|
/* Open the first object again. */
|
|
h1 = dlopen ("reldepmod1.so", RTLD_LAZY | RTLD_GLOBAL);
|
|
if (h1 == NULL)
|
|
{
|
|
printf ("cannot open reldepmod1.so the second time: %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
|
|
/* Get the variable address again. */
|
|
vp = dlsym (h1, "some_var");
|
|
if (vp == NULL)
|
|
{
|
|
printf ("cannot get address of \"some_var\" the second time: %s\n",
|
|
dlerror ());
|
|
exit (1);
|
|
}
|
|
|
|
/* The variable now must have its originial value. */
|
|
if (*vp != 42)
|
|
{
|
|
puts ("variable \"some_var\" reset");
|
|
exit (1);
|
|
}
|
|
|
|
/* Close the first object again, we are done. */
|
|
if (dlclose (h1) != 0)
|
|
{
|
|
printf ("closing h1 failed: %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
if (dlclose (h2) != 0)
|
|
{
|
|
printf ("closing h2 failed: %s\n", dlerror ());
|
|
exit (1);
|
|
}
|
|
|
|
return 0;
|
|
}
|