lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <pthread.h> |
| 3 | |
| 4 | void __attribute__((constructor)) libtest2_ctor(void); |
| 5 | void libtest2_ctor(void) |
| 6 | { |
| 7 | printf("libtest2: constructor!\n"); |
| 8 | } |
| 9 | |
| 10 | void __attribute__((destructor)) libtest2_dtor(void); |
| 11 | void libtest2_dtor(void) |
| 12 | { |
| 13 | printf("libtest2: destructor!\n"); |
| 14 | } |
| 15 | |
| 16 | void function1(void); |
| 17 | void function1(void) |
| 18 | { |
| 19 | printf("libtest2: I am function1!\n"); |
| 20 | } |
| 21 | |
| 22 | void __attribute__((weak)) function2(void); |
| 23 | void function2(void) |
| 24 | { |
| 25 | printf("libtest2: I am weak function2!\n"); |
| 26 | } |
| 27 | |
| 28 | |
| 29 | int libtest2_func(const char *s); |
| 30 | int libtest2_func(const char *s) |
| 31 | { |
| 32 | printf( "libtest2: function1 = %p\n" |
| 33 | "libtest2: function2 = %p\n", |
| 34 | function1, function2); |
| 35 | function1(); |
| 36 | function2(); |
| 37 | return 0; |
| 38 | } |