ifuncmod5.c 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Test STT_GNU_IFUNC symbols without direct function call. */
  2. #include "ifunc-sel.h"
  3. int global __attribute__ ((visibility ("hidden"))) = -1;
  4. static int
  5. one (void)
  6. {
  7. return 1;
  8. }
  9. static int
  10. minus_one (void)
  11. {
  12. return -1;
  13. }
  14. static int
  15. zero (void)
  16. {
  17. return 0;
  18. }
  19. void * foo_ifunc (void) __asm__ ("foo");
  20. __asm__(".type foo, %gnu_indirect_function");
  21. void *
  22. foo_ifunc (void)
  23. {
  24. return ifunc_sel (one, minus_one, zero);
  25. }
  26. void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
  27. __asm__(".type foo_hidden, %gnu_indirect_function");
  28. void *
  29. foo_hidden_ifunc (void)
  30. {
  31. return ifunc_sel (minus_one, one, zero);
  32. }
  33. void * foo_protected_ifunc (void) __asm__ ("foo_protected");
  34. __asm__(".type foo_protected, %gnu_indirect_function");
  35. void *
  36. foo_protected_ifunc (void)
  37. {
  38. return ifunc_sel (one, zero, minus_one);
  39. }
  40. /* Test hidden indirect function. */
  41. __asm__(".hidden foo_hidden");
  42. /* Test protected indirect function. */
  43. __asm__(".protected foo_protected");