[PATCH] Testcase for dladdr
Jakub Jelinek
jakub@redhat.com
Wed Nov 15 05:44:00 GMT 2000
Hi!
This patch adds a testcase whether _dl_argv is setup properly.
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.
--- libc/dlfcn/default.c.jj Sat Sep 16 11:05:17 2000
+++ libc/dlfcn/default.c Wed Nov 15 14:19:57 2000
@@ -1,5 +1,6 @@
#include <dlfcn.h>
#include <stdio.h>
+#include <string.h>
extern int test_in_mod1 (void *);
@@ -12,7 +13,22 @@ 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)
Jakub
More information about the Libc-hacker
mailing list