lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #include <dlfcn.h> |
| 2 | #include <stdio.h> |
| 3 | |
| 4 | |
| 5 | int call_puts; |
| 6 | |
| 7 | static int |
| 8 | do_test (void) |
| 9 | { |
| 10 | call_puts = 1; |
| 11 | |
| 12 | void *h1 = dlopen ("$ORIGIN/order2mod1.so", RTLD_LAZY | RTLD_GLOBAL); |
| 13 | if (h1 == NULL) |
| 14 | { |
| 15 | puts ("cannot load order2mod1"); |
| 16 | return 1; |
| 17 | } |
| 18 | void *h2 = dlopen ("$ORIGIN/order2mod2.so", RTLD_LAZY); |
| 19 | if (h2 == NULL) |
| 20 | { |
| 21 | puts ("cannot load order2mod2"); |
| 22 | return 1; |
| 23 | } |
| 24 | if (dlclose (h1) != 0) |
| 25 | { |
| 26 | puts ("dlclose order2mod1 failed"); |
| 27 | return 1; |
| 28 | } |
| 29 | if (dlclose (h2) != 0) |
| 30 | { |
| 31 | puts ("dlclose order2mod2 failed"); |
| 32 | return 1; |
| 33 | } |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | #define TEST_FUNCTION do_test () |
| 38 | #include "../test-skeleton.c" |
| 39 | |
| 40 | static void |
| 41 | __attribute__ ((destructor)) |
| 42 | fini (void) |
| 43 | { |
| 44 | if (call_puts) |
| 45 | puts ("5"); |
| 46 | } |