mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-21 10:20:06 +00:00
85857f932b
2000-11-15 Jakub Jelinek <jakub@redhat.com> * dlfcn/default.c (main): Add test for dladdr of main returning argv[0] in dli_fname field. 2000-11-15 Jakub Jelinek <jakub@redhat.com> * Makeconfig (run-program-prefix): Move test-static test into the variable. * sysdeps/alpha/dl-machine.h (RTLD_START): Update _dl_argv. * sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Likewise, schedule instructions. * sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise, schedule instructions, fix a bug in copying auxiliary data. * manual/startup.texi (Program Arguments): Fix type of main's envp parameter. Reported by Raúl Núñez de Arenas Coronado <dervishd@linuxfreak.com>.
81 lines
1.8 KiB
C
81 lines
1.8 KiB
C
#include <dlfcn.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
|
|
extern int test_in_mod1 (void *);
|
|
extern int test_in_mod2 (void *);
|
|
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
int (*ifp) (void);
|
|
void *p;
|
|
int result = 0;
|
|
Dl_info info;
|
|
|
|
dladdr(main, &info);
|
|
if (info.dli_fname == NULL)
|
|
{
|
|
printf ("%s: dladdr returns NULL dli_fname\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else if (strcmp (info.dli_fname, argv[0]))
|
|
{
|
|
printf ("%s: dladdr returned '%s' as dli_fname\n", __FILE__, info.dli_fname);
|
|
result = 1;
|
|
}
|
|
else
|
|
printf ("%s: dladdr returned correct dli_fname\n", __FILE__);
|
|
|
|
/* Find function `main'. */
|
|
p = dlsym (RTLD_DEFAULT, "main");
|
|
if (p == NULL)
|
|
{
|
|
printf ("%s: main not found\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else if (p != (void *) &main)
|
|
{
|
|
printf ("%s: wrong address returned for main\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else
|
|
printf ("%s: main correctly found\n", __FILE__);
|
|
|
|
ifp = dlsym (RTLD_DEFAULT, "found_in_mod1");
|
|
if ((void *) ifp == NULL)
|
|
{
|
|
printf ("%s: found_in_mod1 not found\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else if (ifp () != 1)
|
|
{
|
|
printf ("%s: wrong address returned for found_in_mod1\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else
|
|
printf ("%s: found_in_mod1 correctly found\n", __FILE__);
|
|
|
|
ifp = dlsym (RTLD_DEFAULT, "found_in_mod2");
|
|
if ((void *) ifp == NULL)
|
|
{
|
|
printf ("%s: found_in_mod2 not found\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else if (ifp () != 2)
|
|
{
|
|
printf ("%s: wrong address returned for found_in_mod2\n", __FILE__);
|
|
result = 1;
|
|
}
|
|
else
|
|
printf ("%s: found_in_mod2 correctly found\n", __FILE__);
|
|
|
|
result |= test_in_mod1 ((void *) &main);
|
|
|
|
result |= test_in_mod2 ((void *) &main);
|
|
|
|
return result;
|
|
}
|