diff options
Diffstat (limited to 'elf/ltglobmod2.c')
-rw-r--r-- | elf/ltglobmod2.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/elf/ltglobmod2.c b/elf/ltglobmod2.c new file mode 100644 index 0000000000..bc1cd27c40 --- /dev/null +++ b/elf/ltglobmod2.c @@ -0,0 +1,32 @@ +#include <dlfcn.h> +#include <stdio.h> +#include <stdlib.h> + +extern int bar (void); + +int +foo (void) +{ + void *h; + int res; + + /* Load ltglobalmod1 in the global namespace. */ + h = dlopen ("ltglobmod1.so", RTLD_GLOBAL | RTLD_LAZY); + if (h == NULL) + { + printf ("%s: cannot open %s: %s", + __FUNCTION__, "ltglobmod1.so", dlerror ()); + exit (EXIT_FAILURE); + } + + /* Call bar. This is undefined in the DSO. */ + puts ("about to call `bar'"); + fflush (stdout); + res = bar (); + + printf ("bar returned %d\n", res); + + dlclose (h); + + return res != 42; +} |