1 | /* Derived from a test case in |
---|---|
2 | https://sourceware.org/bugzilla/show_bug.cgi?id=1158. */ |
3 | #include <dlfcn.h> |
4 | #include <stdlib.h> |
5 | #include <stdio.h> |
6 | #include <unistd.h> |
7 | |
8 | static int next = 3; |
9 | |
10 | static void |
11 | f1 (void) |
12 | { |
13 | puts (s: "f1"); |
14 | if (next-- != 1) |
15 | _exit (1); |
16 | } |
17 | |
18 | static void |
19 | f2 (void) |
20 | { |
21 | puts (s: "f2"); |
22 | if (next-- != 2) |
23 | _exit (1); |
24 | } |
25 | |
26 | static void |
27 | f3 (void) |
28 | { |
29 | puts (s: "f3"); |
30 | if (next-- != 3) |
31 | _exit (1); |
32 | } |
33 | |
34 | static int |
35 | do_test (void) |
36 | { |
37 | atexit (func: f1); |
38 | |
39 | void *dso = dlopen (file: "$ORIGIN/bug-atexit2-lib.so", RTLD_NOW); |
40 | void (*fn) (void) = (void (*) (void)) dlsym (handle: dso, name: "foo"); |
41 | fn (); |
42 | |
43 | atexit (func: f2); |
44 | |
45 | dlclose (handle: dso); |
46 | |
47 | atexit (func: f3); |
48 | |
49 | return 0; |
50 | } |
51 | |
52 | #define TEST_FUNCTION do_test () |
53 | #include "../test-skeleton.c" |
54 |