2 Copyright (C) 2000-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
27 #define TEST_FUNCTION do_test ()
28 extern int do_test (void);
34 int (*sym
) (void); /* We load ref1 from glreflib1.c. */
39 handle
= dlopen ("glreflib1.so", RTLD_NOW
);
41 error (EXIT_FAILURE
, 0, "cannot load: glreflib1.so");
43 sym
= dlsym (handle
, "ref1");
45 error (EXIT_FAILURE
, 0, "dlsym failed");
47 memset (&info
, 0, sizeof (info
));
48 ret
= dladdr (sym
, &info
);
51 error (EXIT_FAILURE
, 0, "dladdr failed");
53 printf ("ret = %d\n", ret
);
54 printf ("info.dli_fname = %p (\"%s\")\n", info
.dli_fname
, info
.dli_fname
);
55 printf ("info.dli_fbase = %p\n", info
.dli_fbase
);
56 printf ("info.dli_sname = %p (\"%s\")\n", info
.dli_sname
, info
.dli_sname
);
57 printf ("info.dli_saddr = %p\n", info
.dli_saddr
);
59 if (info
.dli_fname
== NULL
)
60 error (EXIT_FAILURE
, 0, "dli_fname is NULL");
61 if (info
.dli_fbase
== NULL
)
62 error (EXIT_FAILURE
, 0, "dli_fbase is NULL");
63 if (info
.dli_sname
== NULL
)
64 error (EXIT_FAILURE
, 0, "dli_sname is NULL");
65 if (info
.dli_saddr
== NULL
)
66 error (EXIT_FAILURE
, 0, "dli_saddr is NULL");
74 #include "../test-skeleton.c"