Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src ld.elf_so: New test for extern initial-exec TLS, PR toolchai...
details: https://anonhg.NetBSD.org/src/rev/156e8b157a43
branches: trunk
changeset: 376077:156e8b157a43
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed May 31 00:18:44 2023 +0000
description:
ld.elf_so: New test for extern initial-exec TLS, PR toolchain/50277.
XXX pullup-10
diffstat:
distrib/sets/lists/tests/mi | 3 +-
distrib/sets/lists/tests/shl.mi | 6 +-
tests/libexec/ld.elf_so/Makefile | 7 +-
tests/libexec/ld.elf_so/helper_def_static/Makefile | 19 ++++
tests/libexec/ld.elf_so/helper_def_static/h_def_static.c | 37 ++++++++
tests/libexec/ld.elf_so/helper_use_static/Makefile | 19 ++++
tests/libexec/ld.elf_so/helper_use_static/h_use_static.c | 37 ++++++++
tests/libexec/ld.elf_so/t_tls_extern.c | 66 ++++++++++++++++
8 files changed, 191 insertions(+), 3 deletions(-)
diffs (273 lines):
diff -r 8cffae025acc -r 156e8b157a43 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Tue May 30 19:05:04 2023 +0000
+++ b/distrib/sets/lists/tests/mi Wed May 31 00:18:44 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1264 2023/05/20 21:32:05 rillig Exp $
+# $NetBSD: mi,v 1.1265 2023/05/31 00:18:44 riastradh Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4168,6 +4168,7 @@
./usr/tests/libexec/ld.elf_so/t_ifunc tests-libexec-tests compattestfile,atf,pic
./usr/tests/libexec/ld.elf_so/t_rtld_r_debug tests-libexec-tests compattestfile,atf,pic
./usr/tests/libexec/ld.elf_so/t_thread_local_dtor tests-libexec-tests compattestfile,atf,pic
+./usr/tests/libexec/ld.elf_so/t_tls_extern tests-libexec-tests compattestfile,atf,pic
./usr/tests/modules tests-sys-tests compattestfile,atf
./usr/tests/net tests-net-tests compattestfile,atf
./usr/tests/net/Atffile tests-net-tests compattestfile,atf
diff -r 8cffae025acc -r 156e8b157a43 distrib/sets/lists/tests/shl.mi
--- a/distrib/sets/lists/tests/shl.mi Tue May 30 19:05:04 2023 +0000
+++ b/distrib/sets/lists/tests/shl.mi Wed May 31 00:18:44 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.11 2017/07/11 15:21:32 joerg Exp $
+# $NetBSD: shl.mi,v 1.12 2023/05/31 00:18:44 riastradh Exp $
#
./usr/tests/lib/csu/h_initfini3_dso.so tests-lib-tests compattestfile,atf
./usr/tests/lib/csu/h_initfini3_dso.so.1 tests-lib-tests compattestfile,atf
@@ -16,6 +16,8 @@
./usr/tests/libexec/ld.elf_so/h_helper_symver_dso1/libh_helper_symver_dso.so.1 tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/h_helper_symver_dso2/libh_helper_symver_dso.so tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/h_helper_symver_dso2/libh_helper_symver_dso.so.1 tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_def_static.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_def_static.so.1 tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/libh_helper_dso1.so tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/libh_helper_dso1.so.1 tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/libh_helper_dso2.so tests-libexec-tests compattestfile,atf
@@ -24,5 +26,7 @@
./usr/tests/libexec/ld.elf_so/libh_helper_dso3.so.1 tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso.so tests-libexec-tests compattestfile,atf
./usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso.so.1 tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_use_static.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_use_static.so.1 tests-libexec-tests compattestfile,atf
./usr/tests/util/id/libfake.so.0 tests-obsolete obsolete
./usr/tests/util/id/libfake.so.0.0 tests-obsolete obsolete
diff -r 8cffae025acc -r 156e8b157a43 tests/libexec/ld.elf_so/Makefile
--- a/tests/libexec/ld.elf_so/Makefile Tue May 30 19:05:04 2023 +0000
+++ b/tests/libexec/ld.elf_so/Makefile Wed May 31 00:18:44 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 2021/05/30 02:26:51 joerg Exp $
+# $NetBSD: Makefile,v 1.13 2023/05/31 00:18:44 riastradh Exp $
#
NOMAN= # defined
@@ -13,10 +13,14 @@ SUBDIR+= helper_dso1 helper_dso3 .WAIT h
helper_symver_dso2 .WAIT \
data
+SUBDIR+= helper_def_static
+SUBDIR+= helper_use_static
+
TESTSDIR= ${TESTSBASE}/libexec/ld.elf_so
TESTS_C+= t_dlerror-cleared t_dlerror-false t_dlinfo t_dlvsym t_ifunc
TESTS_C+= t_rtld_r_debug
+TESTS_C+= t_tls_extern
COPTS.t_rtld_r_debug.c += ${${ACTIVE_CC} == "gcc" :? -Wno-maybe-uninitialized :}
@@ -24,6 +28,7 @@ LDADD.t_dlerror-false= -Wl,-rpath,/var/n
LDADD.t_dlvsym= -Wl,-rpath,${TESTSDIR}/h_helper_symver_dso2
LDADD.t_ifunc= -Wl,-rpath,${TESTSDIR} -lutil
DPADD.t_ifunc= ${LIBUTIL}
+LDADD.t_tls_extern+= -Wl,-rpath,${TESTSDIR}
TESTS_SH+= t_df_1_noopen t_dl_symver t_thread_local_dtor
diff -r 8cffae025acc -r 156e8b157a43 tests/libexec/ld.elf_so/helper_def_static/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_def_static/Makefile Wed May 31 00:18:44 2023 +0000
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1 2023/05/31 00:18:44 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_def_static
+SRCS= h_def_static.c
+
+LIBDIR= ${TESTSBASE}/libexec/ld.elf_so
+SHLIBDIR= ${TESTSBASE}/libexec/ld.elf_so
+SHLIB_MAJOR= 1
+
+MKSTATICLIB= no
+MKPROFILE= no
+MKPICINSTALL= no
+MKLINT= no
+
+NOMAN= # defined
+
+.include <bsd.lib.mk>
diff -r 8cffae025acc -r 156e8b157a43 tests/libexec/ld.elf_so/helper_def_static/h_def_static.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_def_static/h_def_static.c Wed May 31 00:18:44 2023 +0000
@@ -0,0 +1,37 @@
+/* $NetBSD: h_def_static.c,v 1.1 2023/05/31 00:18:44 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+__thread int mysym __attribute__((tls_model("initial-exec"))) = 0;
+
+int *fdef(void);
+int *
+fdef(void)
+{
+
+ return &mysym;
+}
diff -r 8cffae025acc -r 156e8b157a43 tests/libexec/ld.elf_so/helper_use_static/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_use_static/Makefile Wed May 31 00:18:44 2023 +0000
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1 2023/05/31 00:18:44 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_use_static
+SRCS= h_use_static.c
+
+LIBDIR= ${TESTSBASE}/libexec/ld.elf_so
+SHLIBDIR= ${TESTSBASE}/libexec/ld.elf_so
+SHLIB_MAJOR= 1
+
+MKSTATICLIB= no
+MKPROFILE= no
+MKPICINSTALL= no
+MKLINT= no
+
+NOMAN= # defined
+
+.include <bsd.lib.mk>
diff -r 8cffae025acc -r 156e8b157a43 tests/libexec/ld.elf_so/helper_use_static/h_use_static.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_use_static/h_use_static.c Wed May 31 00:18:44 2023 +0000
@@ -0,0 +1,37 @@
+/* $NetBSD: h_use_static.c,v 1.1 2023/05/31 00:18:44 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+__thread int mysym __attribute__((tls_model("initial-exec"))) = 0;
+
+int *fuse(void);
+int *
+fuse(void)
+{
+
+ return &mysym;
+}
diff -r 8cffae025acc -r 156e8b157a43 tests/libexec/ld.elf_so/t_tls_extern.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/t_tls_extern.c Wed May 31 00:18:44 2023 +0000
@@ -0,0 +1,66 @@
+/* $NetBSD: t_tls_extern.c,v 1.1 2023/05/31 00:18:44 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <atf-c.h>
+#include <dlfcn.h>
+
+#define ATF_CHECK_DL(x) ATF_CHECK_MSG(x, "%s: %s", #x, dlerror())
+
+ATF_TC(tls_extern_static);
+ATF_TC_HEAD(tls_extern_static, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "extern __thread for static TLS works");
+}
+ATF_TC_BODY(tls_extern_static, tc)
+{
+ void *def, *use;
+ int *(*fdef)(void), *(*fuse)(void);
+ int *pdef, *puse;
+
+ (void)dlerror();
+ ATF_CHECK_DL(def = dlopen("libh_def_static.so", RTLD_LAZY));
+ ATF_CHECK_DL(use = dlopen("libh_use_static.so", RTLD_LAZY));
+ ATF_CHECK_DL(fdef = dlsym(def, "fdef"));
+ ATF_CHECK_DL(fuse = dlsym(use, "fuse"));
+
+ pdef = (*fdef)();
+ puse = (*fuse)();
+ atf_tc_expect_fail("PR toolchain/50277:"
+ " rtld relocation bug with thread local storage");
+ ATF_CHECK_EQ_MSG(pdef, puse,
+ "%p in defining library != %p in using library",
+ pdef, puse);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, tls_extern_static);
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index