summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-09-15 15:37:16 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-09-15 15:37:16 +0000
commit06b899b496cff14b630ee1214c296b981a702c46 (patch)
tree5947f2e420541c1f9860366a5a3c1b11a710aa1f /regress
parentbb5ece785aa71a8b471c0af0da77cc2ece6b372f (diff)
regress checking dlsym works as expected when called from the main
executable.
Diffstat (limited to 'regress')
-rw-r--r--regress/libexec/ld.so/dlsym/test1/prog2/Makefile18
-rw-r--r--regress/libexec/ld.so/dlsym/test1/prog2/main.c61
2 files changed, 79 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/dlsym/test1/prog2/Makefile b/regress/libexec/ld.so/dlsym/test1/prog2/Makefile
new file mode 100644
index 00000000000..67086eab987
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/prog2/Makefile
@@ -0,0 +1,18 @@
+# $OpenBSD: Makefile,v 1.1 2005/09/15 15:37:15 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= prog2
+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/prog2/main.c b/regress/libexec/ld.so/dlsym/test1/prog2/main.c
new file mode 100644
index 00000000000..6680fd45f5e
--- /dev/null
+++ b/regress/libexec/ld.so/dlsym/test1/prog2/main.c
@@ -0,0 +1,61 @@
+/* $OpenBSD: main.c,v 1.1 2005/09/15 15:37:15 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"
+
+/*
+ * Verifies dlsym works as expected when called from the main executable.
+ * libaa and libc are in the main object group, so their symbols are visable.
+ */
+int
+main()
+{
+ int ret = 0;
+ void *exe_handle = dlopen(NULL, RTLD_LAZY);
+
+ if (dlsym(RTLD_DEFAULT, "aaSymbol") == NULL) {
+ printf("dlsym(RTLD_DEFAULT, \"aaSymbol\") FAILED\n");
+ ret = -1;
+ }
+
+ if (dlsym(RTLD_SELF, "aaSymbol") == NULL) {
+ printf("dlsym(RTLD_SELF, \"aaSymbol\") FAILED\n");
+ ret = -1;
+ }
+
+ if (dlsym(RTLD_NEXT, "aaSymbol") == NULL) {
+ printf("dlsym(RTLD_NEXT, \"aaSymbol\") FAILED\n");
+ ret = -1;
+ }
+
+ if (dlsym(NULL, "aaSymbol") == NULL) {
+ printf("dlsym(RTLD_NEXT, \"aaSymbol\") FAILED\n");
+ ret = -1;
+ }
+
+ if (dlsym(exe_handle, "aaSymbol") == NULL) {
+ printf("dlsym(exe_handle, \"aaSymbol\") FAILED\n");
+ ret = -1;
+ }
+
+ dlclose(exe_handle);
+
+ return (ret);
+}