* elf/constload1.c: Call mtrace.  Check return value of dlclose call.
	* elf/constload2.c: Add destructor to unload constload3.
This commit is contained in:
Ulrich Drepper 2000-08-15 08:23:49 +00:00
parent fc7f617d30
commit 805d2e7d47
3 changed files with 33 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2000-08-15 Ulrich Drepper <drepper@redhat.com> 2000-08-15 Ulrich Drepper <drepper@redhat.com>
* elf/constload1.c: Call mtrace. Check return value of dlclose call.
* elf/constload2.c: Add destructor to unload constload3.
* include/link.h: Include sysd-link.h. * include/link.h: Include sysd-link.h.
* sysdeps/generic/sysd-link.h: New file. * sysdeps/generic/sysd-link.h: New file.
* sysdeps/unix/sysv/linux/sysd-link.h: New file. * sysdeps/unix/sysv/linux/sysd-link.h: New file.

View File

@ -1,6 +1,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <error.h> #include <error.h>
#include <mcheck.h>
#include <stdlib.h> #include <stdlib.h>
int int
@ -10,11 +11,17 @@ main (void)
void *h; void *h;
int ret; int ret;
mtrace ();
h = dlopen ("constload2.so", RTLD_LAZY | RTLD_GLOBAL); h = dlopen ("constload2.so", RTLD_LAZY | RTLD_GLOBAL);
if (h == NULL) if (h == NULL)
error (EXIT_FAILURE, errno, "cannot load module \"constload2.so\""); error (EXIT_FAILURE, errno, "cannot load module \"constload2.so\"");
foo = dlsym (h, "foo"); foo = dlsym (h, "foo");
ret = foo (); ret = foo ();
dlclose (h); if (dlclose (h) != 0)
{
puts ("failed to close");
exit (EXIT_FAILURE);
}
return ret; return ret;
} }

View File

@ -1,4 +1,6 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
extern int bar (void); extern int bar (void);
@ -21,4 +23,24 @@ __attribute__ ((__constructor__))
init (void) init (void)
{ {
h = dlopen ("constload3.so", RTLD_GLOBAL | RTLD_LAZY); h = dlopen ("constload3.so", RTLD_GLOBAL | RTLD_LAZY);
if (h == NULL)
{
puts ("failed to load constload3");
exit (1);
}
else
puts ("succeeded loading constload3");
}
static void
__attribute__ ((__destructor__))
fini (void)
{
if (dlclose (h) != 0)
{
puts ("failed to unload constload3");
exit (1);
}
else
puts ("succeeded unloading constload3");
} }