summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-09-23 18:58:08 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-09-23 18:58:08 +0000
commit79da5b07e676be2caec0827b9ef5d6ff9fd34db7 (patch)
tree6d5e6d8e28e310778d82dacadc4eeb9f01cf77dd /regress
parent4deb55092cc81d26214a2e7ad5ee50b01b407c8a (diff)
add a regress for undefined weak. make sure ld.so doesn't warn on it or
count it as an failure.
Diffstat (limited to 'regress')
-rw-r--r--regress/libexec/ld.so/edgecases/test2/Makefile5
-rw-r--r--regress/libexec/ld.so/edgecases/test2/libaa/Makefile8
-rw-r--r--regress/libexec/ld.so/edgecases/test2/libaa/aa.c30
-rw-r--r--regress/libexec/ld.so/edgecases/test2/libaa/shlib_version2
-rw-r--r--regress/libexec/ld.so/edgecases/test2/prog1/Makefile22
-rw-r--r--regress/libexec/ld.so/edgecases/test2/prog1/main.c39
6 files changed, 106 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/edgecases/test2/Makefile b/regress/libexec/ld.so/edgecases/test2/Makefile
new file mode 100644
index 00000000000..0e57a1a4097
--- /dev/null
+++ b/regress/libexec/ld.so/edgecases/test2/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/23 18:58:07 kurt Exp $
+
+SUBDIR+= libaa prog1
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/edgecases/test2/libaa/Makefile b/regress/libexec/ld.so/edgecases/test2/libaa/Makefile
new file mode 100644
index 00000000000..a1c63f59ddd
--- /dev/null
+++ b/regress/libexec/ld.so/edgecases/test2/libaa/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/23 18:58:07 kurt Exp $
+
+LIB= aa
+SRCS= aa.c
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/edgecases/test2/libaa/aa.c b/regress/libexec/ld.so/edgecases/test2/libaa/aa.c
new file mode 100644
index 00000000000..dbdbd10a71c
--- /dev/null
+++ b/regress/libexec/ld.so/edgecases/test2/libaa/aa.c
@@ -0,0 +1,30 @@
+/* $OpenBSD: aa.c,v 1.1.1.1 2005/09/23 18:58:07 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.
+ */
+
+void undefinedWeakSymbol(void) __attribute__((weak));
+
+/*
+ * aaTest is not called. It just refers to undefinedWeakSymbol
+ * so it is not optimized away.
+ */
+void
+aaTest()
+{
+ if (undefinedWeakSymbol != 0)
+ undefinedWeakSymbol();
+}
diff --git a/regress/libexec/ld.so/edgecases/test2/libaa/shlib_version b/regress/libexec/ld.so/edgecases/test2/libaa/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/edgecases/test2/libaa/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/edgecases/test2/prog1/Makefile b/regress/libexec/ld.so/edgecases/test2/prog1/Makefile
new file mode 100644
index 00000000000..893fe6cae64
--- /dev/null
+++ b/regress/libexec/ld.so/edgecases/test2/prog1/Makefile
@@ -0,0 +1,22 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/23 18:58:07 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
+LDFLAGS+= -Wl,-E
+LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR)
+
+run-regress-${PROG}: ${PROG}
+ ./${PROG}
+ ! ./${PROG} 2>&1 | grep unresolvedWeakSymbol
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/edgecases/test2/prog1/main.c b/regress/libexec/ld.so/edgecases/test2/prog1/main.c
new file mode 100644
index 00000000000..3e2c559a38c
--- /dev/null
+++ b/regress/libexec/ld.so/edgecases/test2/prog1/main.c
@@ -0,0 +1,39 @@
+/* $OpenBSD: main.c,v 1.1.1.1 2005/09/23 18:58:07 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>
+
+/*
+ * this test when run will check that undefined weak symbols do
+ * not generate warning messsages from ld.so
+ */
+int
+main()
+{
+ void *libaa = dlopen("libaa.so", RTLD_LAZY|RTLD_GLOBAL);
+
+ if (libaa == NULL) {
+ printf("dlopen(\"libaa.so\", RTLD_LAZY|RTLD_GLOBAL) FAILED\n");
+ return (1);
+ }
+
+ dlclose(libaa);
+
+ return (0);
+}