* sysdeps/unix/sysv/linux/m68k/sys/procfs.h: New file.
[glibc.git] / dlfcn / tst-dladdr.c
blobd6ad97c3398997439f1ba26d049a060f2977e378
1 /* Test for dladdr.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Volkmar Sieh <vs@caldera.de> and Andreas Jaeger <aj@suse.de>.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #include <dlfcn.h>
22 #include <errno.h>
23 #include <error.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
29 #define TEST_FUNCTION do_test ()
30 extern int do_test (void);
32 int
33 do_test (void)
35 void *handle;
36 int (*sym) (void); /* We load ref1 from glreflib1.c. */
37 Dl_info info;
38 int ret;
41 handle = dlopen ("glreflib1.so", RTLD_NOW);
42 if (handle == NULL)
43 error (EXIT_FAILURE, 0, "cannot load: glreflib1.so");
45 sym = dlsym (handle, "ref1");
46 if (sym == NULL)
47 error (EXIT_FAILURE, 0, "dlsym failed");
49 memset (&info, 0, sizeof (info));
50 ret = dladdr (sym, &info);
52 if (ret == 0)
53 error (EXIT_FAILURE, 0, "dladdr failed");
55 printf ("address of ref1 = %p\n", sym);
56 printf ("ret = %d\n", ret);
57 printf ("info.dli_fname = %p (\"%s\")\n", info.dli_fname, info.dli_fname);
58 printf ("info.dli_fbase = %p\n", info.dli_fbase);
59 printf ("info.dli_sname = %p (\"%s\")\n", info.dli_sname, info.dli_sname);
60 printf ("info.dli_saddr = %p\n", info.dli_saddr);
62 if (info.dli_fname == NULL)
63 error (EXIT_FAILURE, 0, "dli_fname is NULL");
64 if (info.dli_fbase == NULL)
65 error (EXIT_FAILURE, 0, "dli_fbase is NULL");
66 if (info.dli_sname == NULL)
67 error (EXIT_FAILURE, 0, "dli_sname is NULL");
68 if (info.dli_saddr == NULL)
69 error (EXIT_FAILURE, 0, "dli_saddr is NULL");
71 dlclose (handle);
73 return 0;
77 #include "../test-skeleton.c"