elf: Remove LD_PROFILE for static binaries
[glibc.git] / dlfcn / bug-atexit2.c
blob279804dcf2190877aafecef5ebcae1ea445fad35
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>
8 static int next = 3;
10 static void
11 f1 (void)
13 puts ("f1");
14 if (next-- != 1)
15 _exit (1);
18 static void
19 f2 (void)
21 puts ("f2");
22 if (next-- != 2)
23 _exit (1);
26 static void
27 f3 (void)
29 puts ("f3");
30 if (next-- != 3)
31 _exit (1);
34 static int
35 do_test (void)
37 atexit (f1);
39 void *dso = dlopen ("$ORIGIN/bug-atexit2-lib.so", RTLD_NOW);
40 void (*fn) (void) = (void (*) (void)) dlsym (dso, "foo");
41 fn ();
43 atexit (f2);
45 dlclose (dso);
47 atexit (f3);
49 return 0;
52 #define TEST_FUNCTION do_test ()
53 #include "../test-skeleton.c"