summaryrefslogtreecommitdiff
path: root/regress/libexec/ld.so
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-02-10 22:51:42 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-02-10 22:51:42 +0000
commita6524401a41db61ae7519fcd842ce182a1a98505 (patch)
tree54350b4c98c3d71f4a3880c05df2fece1d377611 /regress/libexec/ld.so
parentd0cf1a3683c12d4728861387529f1e41117938bd (diff)
basic weak reference test.
Diffstat (limited to 'regress/libexec/ld.so')
-rw-r--r--regress/libexec/ld.so/weak/Makefile9
-rw-r--r--regress/libexec/ld.so/weak/libstrong/Makefile9
-rw-r--r--regress/libexec/ld.so/weak/libstrong/shlib_version2
-rw-r--r--regress/libexec/ld.so/weak/libstrong/strong.c14
-rw-r--r--regress/libexec/ld.so/weak/libweak/Makefile9
-rw-r--r--regress/libexec/ld.so/weak/libweak/shlib_version2
-rw-r--r--regress/libexec/ld.so/weak/libweak/weak.c16
-rw-r--r--regress/libexec/ld.so/weak/prog/Makefile23
-rw-r--r--regress/libexec/ld.so/weak/prog/defs.h11
-rw-r--r--regress/libexec/ld.so/weak/prog/main.c20
10 files changed, 115 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/weak/Makefile b/regress/libexec/ld.so/weak/Makefile
new file mode 100644
index 00000000000..84da782ee56
--- /dev/null
+++ b/regress/libexec/ld.so/weak/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2002/02/10 22:51:41 fgsch Exp $
+
+SUBDIR+= libstrong libweak prog
+
+regress: _SUBDIRUSE
+
+install:
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/weak/libstrong/Makefile b/regress/libexec/ld.so/weak/libstrong/Makefile
new file mode 100644
index 00000000000..84a3430b18b
--- /dev/null
+++ b/regress/libexec/ld.so/weak/libstrong/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2002/02/10 22:51:41 fgsch Exp $
+
+LIB= strong
+SRCS= strong.c
+CFLAGS+= -I${.CURDIR}/../prog
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/weak/libstrong/shlib_version b/regress/libexec/ld.so/weak/libstrong/shlib_version
new file mode 100644
index 00000000000..1edea46de91
--- /dev/null
+++ b/regress/libexec/ld.so/weak/libstrong/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/weak/libstrong/strong.c b/regress/libexec/ld.so/weak/libstrong/strong.c
new file mode 100644
index 00000000000..2d77a2ad3f7
--- /dev/null
+++ b/regress/libexec/ld.so/weak/libstrong/strong.c
@@ -0,0 +1,14 @@
+/* $OpenBSD: strong.c,v 1.1 2002/02/10 22:51:41 fgsch Exp $ */
+
+/*
+ * Public domain. 2002, Federico Schwindt <fgsch@openbsd.org>.
+ */
+
+#include <sys/cdefs.h>
+#include "defs.h"
+
+int
+func()
+{
+ return (STRONG_REF);
+}
diff --git a/regress/libexec/ld.so/weak/libweak/Makefile b/regress/libexec/ld.so/weak/libweak/Makefile
new file mode 100644
index 00000000000..e5d4e155fea
--- /dev/null
+++ b/regress/libexec/ld.so/weak/libweak/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2002/02/10 22:51:41 fgsch Exp $
+
+LIB= weak
+SRCS= weak.c
+CFLAGS+= -I${.CURDIR}/../prog
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/weak/libweak/shlib_version b/regress/libexec/ld.so/weak/libweak/shlib_version
new file mode 100644
index 00000000000..1edea46de91
--- /dev/null
+++ b/regress/libexec/ld.so/weak/libweak/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/weak/libweak/weak.c b/regress/libexec/ld.so/weak/libweak/weak.c
new file mode 100644
index 00000000000..daa575c3d10
--- /dev/null
+++ b/regress/libexec/ld.so/weak/libweak/weak.c
@@ -0,0 +1,16 @@
+/* $OpenBSD: weak.c,v 1.1 2002/02/10 22:51:41 fgsch Exp $ */
+
+/*
+ * Public domain. 2002, Federico Schwindt <fgsch@openbsd.org>.
+ */
+
+#include <sys/cdefs.h>
+#include "defs.h"
+
+__weak_alias(func,weak_func);
+
+int
+weak_func()
+{
+ return (WEAK_REF);
+}
diff --git a/regress/libexec/ld.so/weak/prog/Makefile b/regress/libexec/ld.so/weak/prog/Makefile
new file mode 100644
index 00000000000..09d58077c2e
--- /dev/null
+++ b/regress/libexec/ld.so/weak/prog/Makefile
@@ -0,0 +1,23 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2002/02/10 22:51:41 fgsch Exp $
+
+.include <bsd.obj.mk>
+
+PROG= prog
+SRCS= main.c
+
+LIBWEAK!= if test -d ${.CURDIR}/../libweak/${__objdir} ; then \
+ echo "${.CURDIR}/../libweak/${__objdir}" ; \
+ else \
+ echo "${.CURDIR}/../libweak" ; \
+ fi
+
+LIBSTRONG!= if test -d ${.CURDIR}/../libstrong/${__objdir} ; then \
+ echo "${.CURDIR}/../libstrong/${__objdir}" ; \
+ else \
+ echo "${.CURDIR}/../libstrong" ; \
+ fi
+
+LDADD+= -Wl,-rpath,${LIBWEAK} -L${LIBWEAK} -lweak
+LDADD+= -Wl,-rpath,${LIBSTRONG} -L${LIBSTRONG} -lstrong
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/weak/prog/defs.h b/regress/libexec/ld.so/weak/prog/defs.h
new file mode 100644
index 00000000000..1e0b2928a1c
--- /dev/null
+++ b/regress/libexec/ld.so/weak/prog/defs.h
@@ -0,0 +1,11 @@
+/* $OpenBSD: defs.h,v 1.1 2002/02/10 22:51:41 fgsch Exp $ */
+
+/*
+ * Public domain. 2002, Federico Schwindt <fgsch@openbsd.org>.
+ */
+
+#define WEAK_REF 0
+#define STRONG_REF 1
+
+int weak_func(void);
+int func(void);
diff --git a/regress/libexec/ld.so/weak/prog/main.c b/regress/libexec/ld.so/weak/prog/main.c
new file mode 100644
index 00000000000..6964eb3ffdb
--- /dev/null
+++ b/regress/libexec/ld.so/weak/prog/main.c
@@ -0,0 +1,20 @@
+/* $OpenBSD: main.c,v 1.1 2002/02/10 22:51:41 fgsch Exp $ */
+
+/*
+ * Public domain. 2002, Federico Schwindt <fgsch@openbsd.org>.
+ */
+
+#include <err.h>
+#include "defs.h"
+
+int
+main(int argc, char **argv)
+{
+ if (weak_func() != WEAK_REF)
+ err(1, "error calling weak reference");
+
+ if (func() != STRONG_REF)
+ err(1, "error calling strong reference");
+
+ return (0);
+}