summaryrefslogtreecommitdiff
path: root/regress/libexec/ld.so/dlclose
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-09-28 15:42:33 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-09-28 15:42:33 +0000
commitf6ba7c6383d734dbd781a6d1b5cc9451658083f8 (patch)
treeb6788e599fe5dfa8873a5ff0f74602d091baad0d /regress/libexec/ld.so/dlclose
parent533868b989d82a44d3c5e1688d5635d60f71f04c (diff)
two new regresses for dlclose. double dlopen("foo") with single
dlclose(foo). mozilla lazy binding example (load_object confusion)
Diffstat (limited to 'regress/libexec/ld.so/dlclose')
-rw-r--r--regress/libexec/ld.so/dlclose/Makefile5
-rw-r--r--regress/libexec/ld.so/dlclose/test1/Makefile5
-rw-r--r--regress/libexec/ld.so/dlclose/test1/Makefile.inc19
-rw-r--r--regress/libexec/ld.so/dlclose/test1/libaa/Makefile11
-rw-r--r--regress/libexec/ld.so/dlclose/test1/libaa/aa.c20
-rw-r--r--regress/libexec/ld.so/dlclose/test1/libaa/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlclose/test1/libbb/Makefile8
-rw-r--r--regress/libexec/ld.so/dlclose/test1/libbb/bb.c45
-rw-r--r--regress/libexec/ld.so/dlclose/test1/libbb/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlclose/test1/prog1/Makefile8
-rw-r--r--regress/libexec/ld.so/dlclose/test1/prog1/main.c48
-rw-r--r--regress/libexec/ld.so/dlclose/test1/prog2/Makefile9
-rw-r--r--regress/libexec/ld.so/dlclose/test1/prog2/main.c49
13 files changed, 231 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/dlclose/Makefile b/regress/libexec/ld.so/dlclose/Makefile
new file mode 100644
index 00000000000..88bb255992b
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/28 15:42:32 kurt Exp $
+
+SUBDIR+= test1
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/dlclose/test1/Makefile b/regress/libexec/ld.so/dlclose/test1/Makefile
new file mode 100644
index 00000000000..68072a1f832
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/28 15:42:32 kurt Exp $
+
+SUBDIR+= libbb libaa prog1 prog2
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/dlclose/test1/Makefile.inc b/regress/libexec/ld.so/dlclose/test1/Makefile.inc
new file mode 100644
index 00000000000..7950cc7b0f3
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/Makefile.inc
@@ -0,0 +1,19 @@
+# $OpenBSD: Makefile.inc,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $
+
+.include <bsd.obj.mk>
+
+AA_DIR=${.CURDIR}/../libaa
+
+AA_OBJDIR!= if [ -d $(AA_DIR)/${__objdir} ]; then \
+ echo "$(AA_DIR)/${__objdir}"; \
+ else \
+ echo "$(AA_DIR)"; \
+ fi
+
+BB_DIR=${.CURDIR}/../libbb
+
+BB_OBJDIR!= if [ -d $(BB_DIR)/${__objdir} ]; then \
+ echo "$(BB_DIR)/${__objdir}"; \
+ else \
+ echo "$(BB_DIR)"; \
+ fi
diff --git a/regress/libexec/ld.so/dlclose/test1/libaa/Makefile b/regress/libexec/ld.so/dlclose/test1/libaa/Makefile
new file mode 100644
index 00000000000..1cc2d2ea07d
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/libaa/Makefile
@@ -0,0 +1,11 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $
+
+LIB= aa
+SRCS= aa.c
+LDADD+= -Wl,-E
+LDADD+= -Wl,-rpath,$(BB_OBJDIR)
+LDADD+= -L$(BB_OBJDIR) -lbb
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlclose/test1/libaa/aa.c b/regress/libexec/ld.so/dlclose/test1/libaa/aa.c
new file mode 100644
index 00000000000..64e3f5e1362
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/libaa/aa.c
@@ -0,0 +1,20 @@
+/* $OpenBSD: aa.c,v 1.1 2005/09/28 15:42:32 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+int aaSymbol;
diff --git a/regress/libexec/ld.so/dlclose/test1/libaa/shlib_version b/regress/libexec/ld.so/dlclose/test1/libaa/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/libaa/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlclose/test1/libbb/Makefile b/regress/libexec/ld.so/dlclose/test1/libbb/Makefile
new file mode 100644
index 00000000000..e3b2464432a
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/libbb/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $
+
+LIB= bb
+SRCS= bb.c
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlclose/test1/libbb/bb.c b/regress/libexec/ld.so/dlclose/test1/libbb/bb.c
new file mode 100644
index 00000000000..debccfd76d5
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/libbb/bb.c
@@ -0,0 +1,45 @@
+/* $OpenBSD: bb.c,v 1.1 2005/09/28 15:42:32 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+int bbSymbol;
+
+void
+bbLazyFun()
+{
+
+}
+
+int
+bbTest1()
+{
+ int ret = 0;
+
+ /* RTLD_DEFAULT should see bbSymbol */
+ if (dlsym(RTLD_DEFAULT, "bbSymbol") == NULL) {
+ printf("dlsym(RTLD_DEFAULT, \"bbSymbol\") == NULL\n");
+ ret = 1;
+ }
+
+ bbLazyFun();
+
+ return (ret);
+}
diff --git a/regress/libexec/ld.so/dlclose/test1/libbb/shlib_version b/regress/libexec/ld.so/dlclose/test1/libbb/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/libbb/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlclose/test1/prog1/Makefile b/regress/libexec/ld.so/dlclose/test1/prog1/Makefile
new file mode 100644
index 00000000000..5c81adf1f43
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/prog1/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $
+
+PROG= prog1
+SRCS= main.c
+LDFLAGS+= -Wl,-E
+LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR)
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/dlclose/test1/prog1/main.c b/regress/libexec/ld.so/dlclose/test1/prog1/main.c
new file mode 100644
index 00000000000..4807dd57223
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/prog1/main.c
@@ -0,0 +1,48 @@
+/* $OpenBSD: main.c,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main()
+{
+ int ret = 0;
+ void *libaa;
+
+ libaa = dlopen("libaa.so", RTLD_LAZY|RTLD_GLOBAL);
+
+ if (libaa == NULL) {
+ printf("dlopen(\"libaa.so\", RTLD_LAZY|RTLD_GLOBAL) FAILED\n");
+ return (1);
+ }
+
+ libaa = dlopen("libaa.so", RTLD_LAZY|RTLD_GLOBAL);
+
+ dlclose(libaa);
+
+ /* RTLD_DEFAULT should see aaSymbol */
+ if (dlsym(RTLD_DEFAULT, "aaSymbol") == NULL) {
+ printf("dlsym(RTLD_DEFAULT, \"aaSymbol\") == NULL\n");
+ ret = 1;
+ }
+
+ dlclose(libaa);
+
+ return (ret);
+}
diff --git a/regress/libexec/ld.so/dlclose/test1/prog2/Makefile b/regress/libexec/ld.so/dlclose/test1/prog2/Makefile
new file mode 100644
index 00000000000..c1eb152956d
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/prog2/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $
+
+PROG= prog2
+SRCS= main.c
+LDFLAGS+= -Wl,-E
+LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR)
+LDFLAGS+= -Wl,-rpath,$(BB_OBJDIR)
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/dlclose/test1/prog2/main.c b/regress/libexec/ld.so/dlclose/test1/prog2/main.c
new file mode 100644
index 00000000000..bcfef7b59a0
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test1/prog2/main.c
@@ -0,0 +1,49 @@
+/* $OpenBSD: main.c,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main()
+{
+ int ret = 0;
+ int (*bbTest1)(void);
+ void *libbb = dlopen("libbb.so", RTLD_LAZY);
+ void *libaa = dlopen("libaa.so", RTLD_LAZY);
+
+ if (libbb == NULL) {
+ printf("dlopen(\"libbb.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ if (libaa == NULL) {
+ printf("dlopen(\"libaa.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ bbTest1 = dlsym(libbb, "bbTest1");
+
+ dlclose(libbb);
+
+ ret = (*bbTest1)();
+
+ dlclose(libaa);
+
+ return (ret);
+}