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