diff options
Diffstat (limited to 'regress')
-rw-r--r-- | regress/libexec/ld.so/Makefile | 4 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlopen/libaa/aa.C | 12 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlopen/libab/ab.C | 11 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlopen/libac/ac.C | 3 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlopen/prog1/prog1.C | 26 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlopen/prog3/main.c | 11 | ||||
-rw-r--r-- | regress/libexec/ld.so/dlopen/prog4/main.c | 4 |
7 files changed, 45 insertions, 26 deletions
diff --git a/regress/libexec/ld.so/Makefile b/regress/libexec/ld.so/Makefile index 5d2ab574315..05e41aaa0fa 100644 --- a/regress/libexec/ld.so/Makefile +++ b/regress/libexec/ld.so/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.5 2005/09/14 16:05:08 kurt Exp $ +# $OpenBSD: Makefile,v 1.6 2005/09/18 19:58:49 drahn Exp $ -SUBDIR+= elf weak dlsym +SUBDIR+= elf weak dlsym dlopen #SUBDIR+= constructor link-order install: diff --git a/regress/libexec/ld.so/dlopen/libaa/aa.C b/regress/libexec/ld.so/dlopen/libaa/aa.C index 49d33bd9bcd..b7a4686b9eb 100644 --- a/regress/libexec/ld.so/dlopen/libaa/aa.C +++ b/regress/libexec/ld.so/dlopen/libaa/aa.C @@ -1,31 +1,33 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: aa.C,v 1.2 2005/09/13 21:03:46 drahn Exp $ + * $OpenBSD: aa.C,v 1.3 2005/09/18 19:58:49 drahn Exp $ */ #include <iostream> #include "aa.h" -int a; +char strbuf[512]; extern "C" { char *libname = "libaa"; }; -extern "C" void +extern "C" char * lib_entry() { + strlcpy(strbuf, libname, sizeof strbuf); + strlcat(strbuf, ":", sizeof strbuf); + strlcat(strbuf, "aa", sizeof strbuf); + return strbuf; std::cout << "called into aa " << libname << " libname " << "\n"; } AA::AA(char *arg) { - a = 1; _name = arg; } AA::~AA() { - std::cout << "dtors AA " << libname << " " << _name << "\n"; } AA foo("A"); diff --git a/regress/libexec/ld.so/dlopen/libab/ab.C b/regress/libexec/ld.so/dlopen/libab/ab.C index 8995bf26ff8..c0183fd0fc7 100644 --- a/regress/libexec/ld.so/dlopen/libab/ab.C +++ b/regress/libexec/ld.so/dlopen/libab/ab.C @@ -1,22 +1,26 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: ab.C,v 1.2 2005/09/13 21:03:46 drahn Exp $ + * $OpenBSD: ab.C,v 1.3 2005/09/18 19:58:50 drahn Exp $ */ #include <iostream> #include <stdlib.h> #include "ab.h" -extern int a; +char strbuf[512]; extern "C" { char *libname = "libab"; }; -extern "C" void +extern "C" char * lib_entry() { + strlcpy(strbuf, libname, sizeof strbuf); + strlcat(strbuf, ":", sizeof strbuf); + strlcat(strbuf, "ab", sizeof strbuf); + return strbuf; std::cout << "called into ab " << libname << " libname " << "\n"; } @@ -27,6 +31,5 @@ BB::BB(char *str) BB::~BB() { - std::cout << "dtors BB " << _name << "\n"; } BB ab("local"); diff --git a/regress/libexec/ld.so/dlopen/libac/ac.C b/regress/libexec/ld.so/dlopen/libac/ac.C index d3ec90f068d..9b9f239a9cb 100644 --- a/regress/libexec/ld.so/dlopen/libac/ac.C +++ b/regress/libexec/ld.so/dlopen/libac/ac.C @@ -1,7 +1,7 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: ac.C,v 1.1 2005/09/17 02:58:54 drahn Exp $ + * $OpenBSD: ac.C,v 1.2 2005/09/18 19:58:50 drahn Exp $ */ #include <iostream> @@ -27,6 +27,5 @@ AC::AC(char *str) AC::~AC() { - std::cout << "dtors AC " << _name << "\n"; } AC ac("local"); diff --git a/regress/libexec/ld.so/dlopen/prog1/prog1.C b/regress/libexec/ld.so/dlopen/prog1/prog1.C index 8ea62669af3..0ffc44a8975 100644 --- a/regress/libexec/ld.so/dlopen/prog1/prog1.C +++ b/regress/libexec/ld.so/dlopen/prog1/prog1.C @@ -1,12 +1,12 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: prog1.C,v 1.2 2005/09/17 01:55:23 drahn Exp $ + * $OpenBSD: prog1.C,v 1.3 2005/09/18 19:58:50 drahn Exp $ */ #include <iostream> #include <dlfcn.h> #include <string.h> -typedef void (v_func)(void); +typedef char * (cp_func)(void); int a; int main() @@ -14,7 +14,9 @@ main() void *handle1; void *handle2; char **libname; - v_func *func; + char *str; + cp_func *func; + int ret = 0; std::cout << "main\n"; handle1 = dlopen("libaa.so.0.0", DL_LAZY); @@ -40,14 +42,22 @@ main() return (1); } - func = (v_func*)dlsym(handle1, "lib_entry"); - (*func)(); + func = (cp_func*)dlsym(handle1, "lib_entry"); + str = (*func)(); + if (strcmp(str, "libaa:aa") != 0) { + printf("func should have returned libaa:aa returned %s\n", str); + ret = 1; + } - func = (v_func*)dlsym(handle2, "lib_entry"); - (*func)(); + func = (cp_func*)dlsym(handle2, "lib_entry"); + str = (*func)(); + if (strcmp(str, "libab:ab") != 0) { + printf("func should have returned libab:ab returned %s\n", str); + ret = 1; + } dlclose(handle1); dlclose(handle2); - return 0; + return ret; } diff --git a/regress/libexec/ld.so/dlopen/prog3/main.c b/regress/libexec/ld.so/dlopen/prog3/main.c index aa43e837ad7..4801e6c5f1c 100644 --- a/regress/libexec/ld.so/dlopen/prog3/main.c +++ b/regress/libexec/ld.so/dlopen/prog3/main.c @@ -1,7 +1,7 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: main.c,v 1.1 2005/09/17 02:58:54 drahn Exp $ + * $OpenBSD: main.c,v 1.2 2005/09/18 19:58:50 drahn Exp $ */ #include <stdio.h> #include <dlfcn.h> @@ -10,7 +10,12 @@ int main() { void *handle; + int ret = 0; + handle = dlopen("libac.so.0.0", RTLD_LAZY); - printf("handle %p\n", handle); - return 0; + if (handle == NULL) { + printf("failed to open libac and it's dependancies\n"); + ret = 1; + } + return ret; } diff --git a/regress/libexec/ld.so/dlopen/prog4/main.c b/regress/libexec/ld.so/dlopen/prog4/main.c index 52e9d020e6d..7bc8faa98f5 100644 --- a/regress/libexec/ld.so/dlopen/prog4/main.c +++ b/regress/libexec/ld.so/dlopen/prog4/main.c @@ -1,7 +1,7 @@ /* * Public Domain 2003 Dale Rahn * - * $OpenBSD: main.c,v 1.1 2005/09/17 02:58:55 drahn Exp $ + * $OpenBSD: main.c,v 1.2 2005/09/18 19:58:50 drahn Exp $ */ #include <stdio.h> #include <dlfcn.h> @@ -9,8 +9,8 @@ int main() { - int ret = 0; void *handle; + int ret = 0; handle = dlopen("libac.so.0.0", RTLD_LAZY); if (handle != NULL) { |