summaryrefslogtreecommitdiff
path: root/regress/libexec
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2005-09-19 21:50:28 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2005-09-19 21:50:28 +0000
commit6bec23400306edbae14a6be5eb33d486fb4e1df3 (patch)
tree5b0050df0c604e91460d78a81ac3c4a7e4a7685a /regress/libexec
parentd6b6bdc4cc02ba248628a5d485047951c71b8d5b (diff)
Verify which symbol is found when same strong symbol found in multiple files.
ok kurt@
Diffstat (limited to 'regress/libexec')
-rw-r--r--regress/libexec/ld.so/dlsym/test3/Makefile4
-rw-r--r--regress/libexec/ld.so/dlsym/test3/libaa/aa.c3
-rw-r--r--regress/libexec/ld.so/dlsym/test3/libbb/bb.c3
-rw-r--r--regress/libexec/ld.so/dlsym/test3/libcc/cc.c3
-rw-r--r--regress/libexec/ld.so/dlsym/test3/prog3/Makefile13
-rw-r--r--regress/libexec/ld.so/dlsym/test3/prog3/main.c76
-rw-r--r--regress/libexec/ld.so/dlsym/test3/prog4/Makefile9
-rw-r--r--regress/libexec/ld.so/dlsym/test3/prog4/main.c63
8 files changed, 169 insertions, 5 deletions
diff --git a/regress/libexec/ld.so/dlsym/test3/Makefile b/regress/libexec/ld.so/dlsym/test3/Makefile
index af3b21c4e9c..b69def0801a 100644
--- a/regress/libexec/ld.so/dlsym/test3/Makefile
+++ b/regress/libexec/ld.so/dlsym/test3/Makefile
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.1 2005/09/19 03:34:18 kurt Exp $
+# $OpenBSD: Makefile,v 1.2 2005/09/19 21:50:27 drahn Exp $
-SUBDIR+= libee libdd libcc libbb libaa prog1 prog2
+SUBDIR+= libee libdd libcc libbb libaa prog1 prog2 prog3 prog4
.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/dlsym/test3/libaa/aa.c b/regress/libexec/ld.so/dlsym/test3/libaa/aa.c
index 41585c4c1cf..34c6811fd56 100644
--- a/regress/libexec/ld.so/dlsym/test3/libaa/aa.c
+++ b/regress/libexec/ld.so/dlsym/test3/libaa/aa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aa.c,v 1.1 2005/09/19 03:34:18 kurt Exp $ */
+/* $OpenBSD: aa.c,v 1.2 2005/09/19 21:50:27 drahn Exp $ */
/*
* Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
@@ -17,3 +17,4 @@
*/
int aaSymbol;
+int commonSymbol;
diff --git a/regress/libexec/ld.so/dlsym/test3/libbb/bb.c b/regress/libexec/ld.so/dlsym/test3/libbb/bb.c
index 187d7197f0e..ca2fb8d045d 100644
--- a/regress/libexec/ld.so/dlsym/test3/libbb/bb.c
+++ b/regress/libexec/ld.so/dlsym/test3/libbb/bb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bb.c,v 1.1 2005/09/19 03:34:18 kurt Exp $ */
+/* $OpenBSD: bb.c,v 1.2 2005/09/19 21:50:27 drahn Exp $ */
/*
* Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
@@ -20,6 +20,7 @@
#include <stdio.h>
int bbSymbol;
+int commonSymbol;
/*
* this test is setup where the main program group dlopen's libbb and libdd
diff --git a/regress/libexec/ld.so/dlsym/test3/libcc/cc.c b/regress/libexec/ld.so/dlsym/test3/libcc/cc.c
index eaaaf7aefaa..e9ca11bcce6 100644
--- a/regress/libexec/ld.so/dlsym/test3/libcc/cc.c
+++ b/regress/libexec/ld.so/dlsym/test3/libcc/cc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cc.c,v 1.1 2005/09/19 03:34:18 kurt Exp $ */
+/* $OpenBSD: cc.c,v 1.2 2005/09/19 21:50:27 drahn Exp $ */
/*
* Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
@@ -17,3 +17,4 @@
*/
int ccSymbol;
+int commonSymbol;
diff --git a/regress/libexec/ld.so/dlsym/test3/prog3/Makefile b/regress/libexec/ld.so/dlsym/test3/prog3/Makefile
new file mode 100644
index 00000000000..7b096dd12cc
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test3/prog3/Makefile
@@ -0,0 +1,13 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/19 21:50:27 drahn Exp $
+
+PROG= prog3
+SRCS= main.c
+CPPFLAGS+= -I$(AA_DIR)
+LDADD+= -laa
+LDFLAGS+= -Wl,-E
+LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR)
+LDFLAGS+= -Wl,-rpath,$(BB_OBJDIR)
+LDFLAGS+= -Wl,-rpath,$(CC_OBJDIR)
+LDFLAGS+= -L$(AA_OBJDIR)
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/dlsym/test3/prog3/main.c b/regress/libexec/ld.so/dlsym/test3/prog3/main.c
new file mode 100644
index 00000000000..4469dab0366
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test3/prog3/main.c
@@ -0,0 +1,76 @@
+/* $OpenBSD: main.c,v 1.1 2005/09/19 21:50:27 drahn 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 mainSymbol;
+
+int
+main()
+{
+ int ret = 1;
+ void *prog;
+ void *libbb;
+ void *libcc;
+ void *p_sym;
+ void *bbsym;
+ void *ccsym;
+ void *a_sym;
+
+
+ prog = dlopen(NULL, RTLD_LAZY);
+ if (prog == NULL) {
+ printf("dlopen(NULL, RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ libbb = dlopen("libbb.so", RTLD_LAZY|RTLD_GLOBAL);
+ if (libbb == NULL) {
+ printf("dlopen(\"libbb.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ libcc = dlopen("libcc.so", RTLD_LAZY|RTLD_GLOBAL);
+ if (libcc == NULL) {
+ printf("dlopen(\"libcc.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ p_sym = dlsym(prog, "commonSymbol");
+ bbsym = dlsym(libbb, "commonSymbol");
+ ccsym = dlsym(libcc, "commonSymbol");
+ a_sym = dlsym(RTLD_DEFAULT, "commonSymbol");
+
+ if(a_sym == p_sym) {
+ ret = 0;
+ }
+ if(a_sym == bbsym) {
+ printf("found common symbol in libbb incorrect location\n");
+ ret = 1;
+ }
+ if(a_sym == ccsym) {
+ printf("found common symbol in libcc incorrect location\n");
+ ret = 1;
+ }
+
+ dlclose(libbb);
+ dlclose(libcc);
+
+ return (ret);
+}
diff --git a/regress/libexec/ld.so/dlsym/test3/prog4/Makefile b/regress/libexec/ld.so/dlsym/test3/prog4/Makefile
new file mode 100644
index 00000000000..00fc6e1cccf
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test3/prog4/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/19 21:50:27 drahn Exp $
+
+PROG= prog4
+SRCS= main.c
+LDFLAGS+= -Wl,-E
+LDFLAGS+= -Wl,-rpath,$(BB_OBJDIR)
+LDFLAGS+= -Wl,-rpath,$(CC_OBJDIR)
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/dlsym/test3/prog4/main.c b/regress/libexec/ld.so/dlsym/test3/prog4/main.c
new file mode 100644
index 00000000000..5412ae04423
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test3/prog4/main.c
@@ -0,0 +1,63 @@
+/* $OpenBSD: main.c,v 1.1 2005/09/19 21:50:27 drahn 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 mainSymbol;
+
+int
+main()
+{
+ int ret = 1;
+ void *libbb;
+ void *libcc;
+ void *bbsym;
+ void *ccsym;
+ void *a_sym;
+
+
+ libbb = dlopen("libbb.so", RTLD_LAZY|RTLD_GLOBAL);
+ if (libbb == NULL) {
+ printf("dlopen(\"libbb.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ libcc = dlopen("libcc.so", RTLD_LAZY|RTLD_GLOBAL);
+ if (libcc == NULL) {
+ printf("dlopen(\"libcc.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ bbsym = dlsym(libbb, "commonSymbol");
+ ccsym = dlsym(libcc, "commonSymbol");
+ a_sym = dlsym(RTLD_DEFAULT, "commonSymbol");
+
+ if(a_sym == bbsym) {
+ ret = 0;
+ }
+ if(a_sym == ccsym) {
+ printf("found common symbol in libcc incorrect location\n");
+ ret = 1;
+ }
+
+ dlclose(libbb);
+ dlclose(libcc);
+
+ return (ret);
+}