ifuncmain5.c 617 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Test STT_GNU_IFUNC symbols with dynamic function pointer only. */
  2. #include <stdlib.h>
  3. extern int foo (void);
  4. extern int foo_protected (void);
  5. typedef int (*foo_p) (void);
  6. extern foo_p __attribute__ ((noinline)) get_foo (void);
  7. extern foo_p __attribute__ ((noinline)) get_foo_protected (void);
  8. foo_p
  9. __attribute__ ((noinline))
  10. get_foo (void)
  11. {
  12. return foo;
  13. }
  14. foo_p
  15. __attribute__ ((noinline))
  16. get_foo_protected (void)
  17. {
  18. return foo_protected;
  19. }
  20. int
  21. main (void)
  22. {
  23. foo_p p;
  24. p = get_foo ();
  25. if ((*p) () != -1)
  26. abort ();
  27. p = get_foo_protected ();
  28. if ((*p) () != 0)
  29. abort ();
  30. return 0;
  31. }