Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
glibc/elf/dblunload.c
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (43 sloc)
965 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <mcheck.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int | |
main (void) | |
{ | |
void *p1; | |
void *p2; | |
int (*fp) (void); | |
int result; | |
mtrace (); | |
p1 = dlopen ("dblloadmod1.so", RTLD_LAZY); | |
if (p1 == NULL) | |
{ | |
printf ("cannot load dblloadmod1.so: %s\n", dlerror ()); | |
exit (EXIT_FAILURE); | |
} | |
p2 = dlopen ("dblloadmod2.so", RTLD_LAZY); | |
if (p2 == NULL) | |
{ | |
printf ("cannot load dblloadmod2.so: %s\n", dlerror ()); | |
exit (EXIT_FAILURE); | |
} | |
if (dlclose (p1) != 0) | |
{ | |
printf ("error while closing dblloadmod1.so: %s\n", dlerror ()); | |
exit (EXIT_FAILURE); | |
} | |
fp = dlsym (p2, "xyzzy"); | |
if (fp == NULL) | |
{ | |
printf ("cannot get function \"xyzzy\": %s\n", dlerror ()); | |
exit (EXIT_FAILURE); | |
} | |
result = fp (); | |
if (dlclose (p2) != 0) | |
{ | |
printf ("error while closing dblloadmod2.so: %s\n", dlerror ()); | |
exit (EXIT_FAILURE); | |
} | |
return result; | |
} |