From: Roland McGrath Date: Wed, 6 Apr 2005 01:42:58 +0000 (+0000) Subject: 2005-03-03 Jakub Jelinek X-Git-Tag: cvs/glibc-2_3_5~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30c69f4d44c306306d479f06712a6bcb894d4271;p=thirdparty%2Fglibc.git 2005-03-03 Jakub Jelinek [BZ #821] * elf/Makefile: Add rules to build and run unload3 test. * elf/unload3.c: New test. * elf/unload3mod1.c: New file. * elf/unload3mod2.c: New file. * elf/unload3mod3.c: New file. * elf/unload3mod4.c: New file. --- diff --git a/elf/unload3.c b/elf/unload3.c new file mode 100644 index 00000000000..6f1af707e60 --- /dev/null +++ b/elf/unload3.c @@ -0,0 +1,41 @@ +#include +#include + +int +main (void) +{ + void *g = dlopen ("unload3mod1.so", RTLD_GLOBAL | RTLD_NOW); + void *h = dlopen ("unload3mod2.so", RTLD_GLOBAL | RTLD_NOW); + if (g == NULL || h == NULL) + { + printf ("dlopen unload3mod{1,2}.so failed: %p %p\n", g, h); + return 1; + } + dlclose (h); + dlclose (g); + + g = dlopen ("unload3mod3.so", RTLD_GLOBAL | RTLD_NOW); + h = dlopen ("unload3mod4.so", RTLD_GLOBAL | RTLD_NOW); + if (g == NULL || h == NULL) + { + printf ("dlopen unload3mod{3,4}.so failed: %p %p\n", g, h); + return 1; + } + + int (*fn) (int); + fn = dlsym (h, "bar"); + if (fn == NULL) + { + puts ("dlsym failed"); + return 1; + } + + int val = fn (16); + if (val != 24) + { + printf ("bar returned %d != 24\n", val); + return 1; + } + + return 0; +} diff --git a/elf/unload3mod1.c b/elf/unload3mod1.c new file mode 100644 index 00000000000..e886b11c186 --- /dev/null +++ b/elf/unload3mod1.c @@ -0,0 +1 @@ +int dummy1; diff --git a/elf/unload3mod2.c b/elf/unload3mod2.c new file mode 100644 index 00000000000..03252a523bf --- /dev/null +++ b/elf/unload3mod2.c @@ -0,0 +1 @@ +int dummy2; diff --git a/elf/unload3mod3.c b/elf/unload3mod3.c new file mode 100644 index 00000000000..046022c55d7 --- /dev/null +++ b/elf/unload3mod3.c @@ -0,0 +1,8 @@ +#include + +int +foo (int x) +{ + puts ("foo"); + return x * 2; +} diff --git a/elf/unload3mod4.c b/elf/unload3mod4.c new file mode 100644 index 00000000000..4586ff7383e --- /dev/null +++ b/elf/unload3mod4.c @@ -0,0 +1,11 @@ +#include + +int +bar (int x) +{ + puts ("bar"); + fflush (stdout); + x = foo (x - 4); + puts ("bar after foo"); + return x; +}