diff options
Diffstat (limited to 'regress/libexec/ld.so/dlopen/prog1/prog1.C')
-rw-r--r-- | regress/libexec/ld.so/dlopen/prog1/prog1.C | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/regress/libexec/ld.so/dlopen/prog1/prog1.C b/regress/libexec/ld.so/dlopen/prog1/prog1.C index cad1faf98fb..8ea62669af3 100644 --- a/regress/libexec/ld.so/dlopen/prog1/prog1.C +++ b/regress/libexec/ld.so/dlopen/prog1/prog1.C @@ -1,10 +1,11 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: prog1.C,v 1.1 2005/09/13 20:51:39 drahn Exp $ + * $OpenBSD: prog1.C,v 1.2 2005/09/17 01:55:23 drahn Exp $ */ #include <iostream> #include <dlfcn.h> +#include <string.h> typedef void (v_func)(void); int a; int @@ -18,26 +19,35 @@ main() std::cout << "main\n"; handle1 = dlopen("libaa.so.0.0", DL_LAZY); if (handle1 == NULL) { - std::cout << "handle1 failed\n"; + std::cout << "handle1 open libaa failed\n"; + return (1); } handle2 = dlopen("libab.so.0.0", DL_LAZY); if (handle2 == NULL) { - std::cout << "handle1 failed\n"; + std::cout << "handle2 open libab failed\n"; + return (1); } - std::cout << "loaded \n"; + libname = (char **)dlsym(handle1, "libname"); - std::cout << "handle1 is " << *libname << "\n"; + if (strcmp(*libname, "libaa") != 0) { + std::cout << "handle1 is " << *libname << "\n"; + return (1); + } + libname = (char **)dlsym(handle2, "libname"); - std::cout << "handle2 is " << *libname << "\n"; + if (strcmp(*libname, "libab") != 0) { + std::cout << "handle2 is " << *libname << "\n"; + return (1); + } + func = (v_func*)dlsym(handle1, "lib_entry"); (*func)(); + func = (v_func*)dlsym(handle2, "lib_entry"); (*func)(); - std::cout << "closing \n"; dlclose(handle1); dlclose(handle2); - std::cout << "all done \n"; return 0; } |