tst-addr1.c 652 B

12345678910111213141516171819202122232425
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. static int
  5. do_test (void)
  6. {
  7. Dl_info i;
  8. if (dladdr (&printf, &i) == 0)
  9. {
  10. puts ("not found");
  11. return 1;
  12. }
  13. printf ("found symbol %s in %s\n", i.dli_sname, i.dli_fname);
  14. return i.dli_sname == NULL
  15. || (strcmp (i.dli_sname, "printf") != 0
  16. /* On architectures which create PIC code by default
  17. &printf may resolve to an address in libc.so
  18. rather than in the binary. printf and _IO_printf
  19. are aliased and which one comes first in the
  20. hash table is up to the linker. */
  21. && strcmp (i.dli_sname, "_IO_printf") != 0);
  22. }
  23. #include <support/test-driver.c>