summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-09-14 15:59:38 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-09-14 15:59:38 +0000
commit3b3dd8b71c165c8c139181d26655d29e189021f6 (patch)
tree0a421b6b873760edd4bc989b0c4c45e6b05f4d4e /regress
parent5a033af74b50bce82492e26561acfcf9321729e7 (diff)
Add a regress test for dlsym special handles. Checks that duplicate symbols
are handled right for a simple case.
Diffstat (limited to 'regress')
-rw-r--r--regress/libexec/ld.so/dlsym/Makefile5
-rw-r--r--regress/libexec/ld.so/dlsym/test1/Makefile5
-rw-r--r--regress/libexec/ld.so/dlsym/test1/libaa/Makefile3
-rw-r--r--regress/libexec/ld.so/dlsym/test1/libaa/aa.c84
-rw-r--r--regress/libexec/ld.so/dlsym/test1/libaa/aa.h19
-rw-r--r--regress/libexec/ld.so/dlsym/test1/libaa/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlsym/test1/prog1/Makefile18
-rw-r--r--regress/libexec/ld.so/dlsym/test1/prog1/main.c29
8 files changed, 165 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/dlsym/Makefile b/regress/libexec/ld.so/dlsym/Makefile
new file mode 100644
index 00000000000..b7757ba2d93
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/14 15:59:37 kurt Exp $
+
+SUBDIR+= test1
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/dlsym/test1/Makefile b/regress/libexec/ld.so/dlsym/test1/Makefile
new file mode 100644
index 00000000000..a6d87b20730
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/14 15:59:37 kurt Exp $
+
+SUBDIR+= libaa prog1
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/dlsym/test1/libaa/Makefile b/regress/libexec/ld.so/dlsym/test1/libaa/Makefile
new file mode 100644
index 00000000000..0c867307e08
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/libaa/Makefile
@@ -0,0 +1,3 @@
+LIB=aa
+SRCS= aa.c
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlsym/test1/libaa/aa.c b/regress/libexec/ld.so/dlsym/test1/libaa/aa.c
new file mode 100644
index 00000000000..e66ceda0ec6
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/libaa/aa.c
@@ -0,0 +1,84 @@
+/* $OpenBSD: aa.c,v 1.1 2005/09/14 15:59:37 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>
+#include "aa.h"
+
+void
+sigprocmask() {
+}
+
+/*
+ * aaTest verifies dlsym works as expected with a simple case of duplicate
+ * symbols. prog1, libaa and libc all have the sigprocmask symbol and are
+ * linked with prog1 with libaa before libc. Depending on how dlsym is called
+ * the symbol for sigprocmask should come from prog1 libaa or libc.
+ */
+int
+aaTest()
+{
+ int ret = 0;
+ void *value;
+ void *libaa_sigprocmask = dlsym(dlopen("libaa.so", RTLD_LAZY), "sigprocmask");
+ void *libc_sigprocmask = dlsym(dlopen("libc.so", RTLD_LAZY), "sigprocmask");
+
+ printf("sigprocmask == %p\n", &sigprocmask);
+ printf("libaa_sigprocmask == %p\n", libaa_sigprocmask);
+ printf("libc_sigprocmask == %p\n", libc_sigprocmask);
+
+ /* basic sanity check */
+ if (libaa_sigprocmask == &sigprocmask || libc_sigprocmask == &sigprocmask ||
+ libc_sigprocmask == libaa_sigprocmask || libaa_sigprocmask == NULL ||
+ libc_sigprocmask == NULL) {
+ printf("dlsym(handle, ...)\n FAILED\n");
+ return (-1);
+ }
+
+ value = dlsym(RTLD_DEFAULT, "sigprocmask");
+ if (value != &sigprocmask) {
+ printf("dlsym(RTLD_DEFAULT, \"sigprocmask\") == %p FAILED\n", value);
+ printf("\twas expecting == %p (&sigprocmask)\n", &sigprocmask);
+ ret = -1;
+ }
+
+ value = dlsym(RTLD_SELF, "sigprocmask");
+ if (value != libaa_sigprocmask) {
+ printf("dlsym(RTLD_SELF, \"sigprocmask\") == %p FAILED\n", value);
+ printf("\twas expecting == %p (libaa_sigprocmask)\n", libaa_sigprocmask);
+ printf("FAILED\n");
+ ret = -1;
+ }
+
+ value = dlsym(RTLD_NEXT, "sigprocmask");
+ if (value != libc_sigprocmask) {
+ printf("dlsym(RTLD_NEXT, \"sigprocmask\") == %p FAILED\n", value);
+ printf("\twas expecting == %p (libc_sigprocmask)\n", libc_sigprocmask);
+ ret = -1;
+ }
+
+ value = dlsym(NULL, "sigprocmask");
+ if (value != libaa_sigprocmask) {
+ printf("dlsym(NULL, \"sigprocmask\") == %p FAILED\n", value);
+ printf("\twas expecting == %p (libaa_sigprocmask)\n", libaa_sigprocmask);
+ ret = -1;
+ }
+
+ return (ret);
+}
diff --git a/regress/libexec/ld.so/dlsym/test1/libaa/aa.h b/regress/libexec/ld.so/dlsym/test1/libaa/aa.h
new file mode 100644
index 00000000000..7e30b57a785
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/libaa/aa.h
@@ -0,0 +1,19 @@
+/* $OpenBSD: aa.h,v 1.1.1.1 2005/09/14 15:59:37 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 aaTest();
diff --git a/regress/libexec/ld.so/dlsym/test1/libaa/shlib_version b/regress/libexec/ld.so/dlsym/test1/libaa/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/libaa/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlsym/test1/prog1/Makefile b/regress/libexec/ld.so/dlsym/test1/prog1/Makefile
new file mode 100644
index 00000000000..6e61b643d42
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/prog1/Makefile
@@ -0,0 +1,18 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/14 15:59:37 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
+
+PROG= prog1
+SRCS= main.c
+CPPFLAGS+= -I$(AA_DIR)
+LDADD= -Wl,-E -Wl,-rpath,$(AA_OBJDIR) -L$(AA_OBJDIR) -laa
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/dlsym/test1/prog1/main.c b/regress/libexec/ld.so/dlsym/test1/prog1/main.c
new file mode 100644
index 00000000000..9d54b97153a
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/prog1/main.c
@@ -0,0 +1,29 @@
+/* $OpenBSD: main.c,v 1.1.1.1 2005/09/14 15:59:37 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 "aa.h"
+
+void
+sigprocmask() {
+}
+
+int
+main()
+{
+ return (aaTest());
+}