libtest2.c 721 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. extern int __pthread_mutex_init (void);
  4. void __attribute__((constructor)) libtest2_ctor(void)
  5. {
  6. printf("I am the libtest2 constructor!\n");
  7. }
  8. void __attribute__((destructor)) libtest2_dtor(void)
  9. {
  10. printf("I am the libtest2 destructor!\n");
  11. }
  12. void function1(void)
  13. {
  14. printf("libtest2: I am overriding function1!\n");
  15. }
  16. void __attribute__((weak)) function2(void)
  17. {
  18. printf("libtest2: I am function2 from libtest2!\n");
  19. }
  20. int libtest2_func(const char *s)
  21. {
  22. function1();
  23. function2();
  24. printf( "libtest2: function1 = %p\n"
  25. "libtest2: function2 = %p\n"
  26. "libtest2: message from main() = '%s'\n",
  27. function1, function2, s);
  28. return 0;
  29. }