Back to index

glibc  2.9
tst-addr1.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 #include <string.h>
00004 
00005 static int
00006 do_test (void)
00007 {
00008   Dl_info i;
00009   if (dladdr (&printf, &i) == 0)
00010     {
00011       puts ("not found");
00012       return 1;
00013     }
00014   printf ("found symbol %s in %s\n", i.dli_sname, i.dli_fname);
00015   return i.dli_sname == NULL
00016         || (strcmp (i.dli_sname, "printf") != 0
00017             /* On architectures which create PIC code by default
00018               &printf may resolve to an address in libc.so
00019               rather than in the binary.  printf and _IO_printf
00020               are aliased and which one comes first in the
00021               hash table is up to the linker.  */
00022             && strcmp (i.dli_sname, "_IO_printf") != 0);
00023 }
00024 
00025 #define TEST_FUNCTION do_test ()
00026 #include "../test-skeleton.c"