summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libc/Makefile4
-rw-r--r--regress/lib/libc/atexit/atexit_test.c6
-rw-r--r--regress/lib/libc/cxa-atexit/Makefile13
-rw-r--r--regress/lib/libc/cxa-atexit/libgd1/Makefile9
-rw-r--r--regress/lib/libc/cxa-atexit/libgd1/gd1.C32
-rw-r--r--regress/lib/libc/cxa-atexit/libgd1/shlib_version2
-rw-r--r--regress/lib/libc/cxa-atexit/libgd2/Makefile9
-rw-r--r--regress/lib/libc/cxa-atexit/libgd2/gd2.C32
-rw-r--r--regress/lib/libc/cxa-atexit/libgd2/shlib_version2
-rw-r--r--regress/lib/libc/cxa-atexit/test1/Makefile29
-rw-r--r--regress/lib/libc/cxa-atexit/test1/test1.C63
11 files changed, 196 insertions, 5 deletions
diff --git a/regress/lib/libc/Makefile b/regress/lib/libc/Makefile
index e3e29ddd692..689f87aa03b 100644
--- a/regress/lib/libc/Makefile
+++ b/regress/lib/libc/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.25 2007/05/17 03:02:32 ray Exp $
+# $OpenBSD: Makefile,v 1.26 2007/09/03 14:42:43 millert Exp $
-SUBDIR+= _setjmp alloca atexit basename db dirname getaddrinfo
+SUBDIR+= _setjmp alloca atexit basename cxa-atexit db dirname getaddrinfo
SUBDIR+= getcap getopt_long hsearch longjmp locale malloc
SUBDIR+= netdb popen regex setjmp setjmp-signal sigreturn sigsetjmp
SUBDIR+= sprintf strerror strtod strtonum telldir time vis
diff --git a/regress/lib/libc/atexit/atexit_test.c b/regress/lib/libc/atexit/atexit_test.c
index efa2274168b..3dd0b62c3ec 100644
--- a/regress/lib/libc/atexit/atexit_test.c
+++ b/regress/lib/libc/atexit/atexit_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atexit_test.c,v 1.5 2003/09/02 23:52:16 david Exp $ */
+/* $OpenBSD: atexit_test.c,v 1.6 2007/09/03 14:42:44 millert Exp $ */
/*
* Copyright (c) 2002 Daniel Hartmeier
@@ -79,7 +79,7 @@ main(int argc, char *argv[])
/* this is supposed to segfault */
if (!strcmp(argv[1], "-invalid-atexit")) {
signal(SIGSEGV, handle_signal);
- __atexit->fns[0] = handle_invalid;
+ __atexit->fns[0].fn_ptr.std_func = handle_invalid;
} else if (!strcmp(argv[1], "-invalid-cleanup")) {
struct atexit *p = __atexit;
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
p = p->next;
if (p == NULL)
fprintf(stderr, "p == NULL, no page found\n");
- p->fns[0] = handle_invalid;
+ p->fns[0].fn_ptr.std_func = handle_invalid;
}
__atexit_register_cleanup(handle_cleanup);
counter = 0;
diff --git a/regress/lib/libc/cxa-atexit/Makefile b/regress/lib/libc/cxa-atexit/Makefile
new file mode 100644
index 00000000000..ffd83fe1ca4
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/Makefile
@@ -0,0 +1,13 @@
+# $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $
+
+.include <bsd.own.mk>
+
+USE_GCC3?=No
+
+.if ${USE_GCC3:L} == "yes"
+SUBDIR+= libgd1 libgd2 test1
+.endif
+
+install:
+
+.include <bsd.subdir.mk>
diff --git a/regress/lib/libc/cxa-atexit/libgd1/Makefile b/regress/lib/libc/cxa-atexit/libgd1/Makefile
new file mode 100644
index 00000000000..958b726d28e
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/libgd1/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $
+
+LIB=gd1
+SRCS= gd1.C
+NOPROFILE=yes
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/lib/libc/cxa-atexit/libgd1/gd1.C b/regress/lib/libc/cxa-atexit/libgd1/gd1.C
new file mode 100644
index 00000000000..b3ecd56d91f
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/libgd1/gd1.C
@@ -0,0 +1,32 @@
+/* $OpenBSD: gd1.C,v 1.1 2007/09/03 14:42:44 millert Exp $ */
+
+/*
+ * Copyright (c) 2007 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 <stdio.h>
+
+extern int check1;
+
+struct global_destructor_test_obj1 {
+ inline ~global_destructor_test_obj1() {
+ check1 = 0;
+ }
+};
+
+extern "C" void gd_test1()
+{
+ static global_destructor_test_obj1 gdt;
+}
diff --git a/regress/lib/libc/cxa-atexit/libgd1/shlib_version b/regress/lib/libc/cxa-atexit/libgd1/shlib_version
new file mode 100644
index 00000000000..97c9f92d6b8
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/libgd1/shlib_version
@@ -0,0 +1,2 @@
+major=0
+minor=0
diff --git a/regress/lib/libc/cxa-atexit/libgd2/Makefile b/regress/lib/libc/cxa-atexit/libgd2/Makefile
new file mode 100644
index 00000000000..7ca21d8bd27
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/libgd2/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $
+
+LIB=gd2
+SRCS= gd2.C
+NOPROFILE=yes
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/lib/libc/cxa-atexit/libgd2/gd2.C b/regress/lib/libc/cxa-atexit/libgd2/gd2.C
new file mode 100644
index 00000000000..69e7ffb220f
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/libgd2/gd2.C
@@ -0,0 +1,32 @@
+/* $OpenBSD: gd2.C,v 1.1 2007/09/03 14:42:44 millert Exp $ */
+
+/*
+ * Copyright (c) 2007 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 <stdio.h>
+
+extern int check2;
+
+struct global_destructor_test_obj2 {
+ inline ~global_destructor_test_obj2() {
+ check2 = 0;
+ }
+};
+
+extern "C" void gd_test2()
+{
+ static global_destructor_test_obj2 gdt;
+}
diff --git a/regress/lib/libc/cxa-atexit/libgd2/shlib_version b/regress/lib/libc/cxa-atexit/libgd2/shlib_version
new file mode 100644
index 00000000000..97c9f92d6b8
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/libgd2/shlib_version
@@ -0,0 +1,2 @@
+major=0
+minor=0
diff --git a/regress/lib/libc/cxa-atexit/test1/Makefile b/regress/lib/libc/cxa-atexit/test1/Makefile
new file mode 100644
index 00000000000..533392d144e
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/test1/Makefile
@@ -0,0 +1,29 @@
+# $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $
+
+.include <bsd.obj.mk>
+
+GD1_DIR=${.CURDIR}/../libgd1
+GD1_OBJDIR!= if [ -d $(GD1_DIR)/${__objdir} ]; then \
+ echo "$(GD1_DIR)/${__objdir}"; \
+ else \
+ echo "$(GD1_DIR)"; \
+ fi
+
+GD2_DIR=${.CURDIR}/../libgd2
+GD2_OBJDIR!= if [ -d $(GD2_DIR)/${__objdir} ]; then \
+ echo "$(GD2_DIR)/${__objdir}"; \
+ else \
+ echo "$(GD2_DIR)"; \
+ fi
+
+PROG= test1
+
+SRCS= test1.C
+
+CFLAGS+= -DLIBGD1="\"$(GD1_OBJDIR)/libgd1.so\""
+CFLAGS+= -DLIBGD2="\"$(GD2_OBJDIR)/libgd2.so\""
+LDFLAGS+= -Wl,-E
+
+NOMAN=
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libc/cxa-atexit/test1/test1.C b/regress/lib/libc/cxa-atexit/test1/test1.C
new file mode 100644
index 00000000000..75fb967a904
--- /dev/null
+++ b/regress/lib/libc/cxa-atexit/test1/test1.C
@@ -0,0 +1,63 @@
+/* $OpenBSD: test1.C,v 1.1 2007/09/03 14:42:44 millert Exp $ */
+
+/*
+ * Copyright (c) 2007 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 <err.h>
+#include <stdio.h>
+
+int check1, check2;
+
+int
+main()
+{
+ void *libgd1, *libgd2;
+ void (*gd_test)();
+ int i;
+
+ for (i=0; i < 50; i++) {
+ check1 = check2 = 1;
+
+ libgd1 = dlopen(LIBGD1, RTLD_LAZY);
+ if (libgd1 == NULL)
+ errx(1, "dlopen(%s, RTLD_LAZY) FAILED\n", LIBGD1);
+
+ gd_test = (void (*)())dlsym(libgd1, "gd_test1");
+ if (gd_test == NULL)
+ errx(1, "dlsym(libgd1, \"gd_test1\") FAILED\n");
+
+ (*gd_test)();
+
+ libgd2 = dlopen(LIBGD2, RTLD_LAZY);
+ if (libgd2 == NULL)
+ errx(1, "dlopen(%s, RTLD_LAZY) FAILED\n", LIBGD2);
+
+ gd_test = (void (*)())dlsym(libgd2, "gd_test2");
+ if (gd_test == NULL)
+ errx(1, "dlsym(libgd2, \"gd_test2\") FAILED\n");
+
+ (*gd_test)();
+
+ dlclose(libgd1);
+ dlclose(libgd2);
+
+ if (check1 || check2)
+ errx(1, "global destructors not called\n");
+ }
+
+ return (0);
+}