Module Name: src
Committed By: riastradh
Date: Thu Jun 1 20:50:19 UTC 2023
Modified Files:
src/distrib/sets/lists/debug: shl.mi
src/distrib/sets/lists/tests: shl.mi
src/tests/libexec/ld.elf_so: Makefile t_tls_extern.c
Added Files:
src/tests/libexec/ld.elf_so/helper_def_dynamic: Makefile
h_def_dynamic.c
src/tests/libexec/ld.elf_so/helper_use_dynamic: Makefile
h_use_dynamic.c
Log Message:
ld.elf_so: Test extern dynamic TLS too.
XXX pullup-10
To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.12 -r1.13 src/distrib/sets/lists/tests/shl.mi
cvs rdiff -u -r1.15 -r1.16 src/tests/libexec/ld.elf_so/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/libexec/ld.elf_so/t_tls_extern.c
cvs rdiff -u -r0 -r1.1 \
src/tests/libexec/ld.elf_so/helper_def_dynamic/Makefile \
src/tests/libexec/ld.elf_so/helper_def_dynamic/h_def_dynamic.c
cvs rdiff -u -r0 -r1.1 \
src/tests/libexec/ld.elf_so/helper_use_dynamic/Makefile \
src/tests/libexec/ld.elf_so/helper_use_dynamic/h_use_dynamic.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/debug/shl.mi
diff -u src/distrib/sets/lists/debug/shl.mi:1.306 src/distrib/sets/lists/debug/shl.mi:1.307
--- src/distrib/sets/lists/debug/shl.mi:1.306 Wed May 31 13:02:10 2023
+++ src/distrib/sets/lists/debug/shl.mi Thu Jun 1 20:50:18 2023
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.306 2023/05/31 13:02:10 riastradh Exp $
+# $NetBSD: shl.mi,v 1.307 2023/06/01 20:50:18 riastradh Exp $
./usr/lib/libbfd_g.a comp-c-debuglib debuglib,compatfile,binutils
./usr/libdata/debug/lib base-sys-usr debug,dynamicroot,compatdir
./usr/libdata/debug/lib/libavl.so.0.0.debug comp-zfs-debug debug,dynamicroot,zfs
@@ -363,11 +363,13 @@
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_helper_symver_dso1/libh_helper_symver_dso.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_helper_symver_dso2/libh_helper_symver_dso.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_thread_local_dtor.debug tests-libexec-debug debug,compattestfile,atf
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_def_dynamic.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_def_static.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_dso1.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_dso2.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_dso3.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso.so.1.debug tests-libexec-debug debug,compattestfile,atf
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_use_dynamic.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_use_static.so.1.debug tests-libexec-debug debug,compattestfile,atf
./usr/tests/libexec/ld.elf_so/h_helper_symver_dso0/libh_helper_symver_dso_g.a comp-c-debuglib atf,debuglib,compattestfile
./usr/tests/libexec/ld.elf_so/h_helper_symver_dso1/libh_helper_symver_dso_g.a comp-c-debuglib atf,debuglib,compattestfile
Index: src/distrib/sets/lists/tests/shl.mi
diff -u src/distrib/sets/lists/tests/shl.mi:1.12 src/distrib/sets/lists/tests/shl.mi:1.13
--- src/distrib/sets/lists/tests/shl.mi:1.12 Wed May 31 00:18:44 2023
+++ src/distrib/sets/lists/tests/shl.mi Thu Jun 1 20:50:18 2023
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.12 2023/05/31 00:18:44 riastradh Exp $
+# $NetBSD: shl.mi,v 1.13 2023/06/01 20:50:18 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_dynamic.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_def_dynamic.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
@@ -26,6 +28,8 @@
./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_dynamic.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_use_dynamic.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
Index: src/tests/libexec/ld.elf_so/Makefile
diff -u src/tests/libexec/ld.elf_so/Makefile:1.15 src/tests/libexec/ld.elf_so/Makefile:1.16
--- src/tests/libexec/ld.elf_so/Makefile:1.15 Wed May 31 01:06:43 2023
+++ src/tests/libexec/ld.elf_so/Makefile Thu Jun 1 20:50:18 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2023/05/31 01:06:43 riastradh Exp $
+# $NetBSD: Makefile,v 1.16 2023/06/01 20:50:18 riastradh Exp $
#
NOMAN= # defined
@@ -13,8 +13,10 @@ SUBDIR+= helper_dso1 helper_dso3 .WAIT h
helper_symver_dso2 .WAIT \
data
+SUBDIR+= helper_def_dynamic
SUBDIR+= helper_def_static
SUBDIR+= .WAIT
+SUBDIR+= helper_use_dynamic
SUBDIR+= helper_use_static
TESTSDIR= ${TESTSBASE}/libexec/ld.elf_so
Index: src/tests/libexec/ld.elf_so/t_tls_extern.c
diff -u src/tests/libexec/ld.elf_so/t_tls_extern.c:1.3 src/tests/libexec/ld.elf_so/t_tls_extern.c:1.4
--- src/tests/libexec/ld.elf_so/t_tls_extern.c:1.3 Thu Jun 1 20:48:30 2023
+++ src/tests/libexec/ld.elf_so/t_tls_extern.c Thu Jun 1 20:50:18 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: t_tls_extern.c,v 1.3 2023/06/01 20:48:30 riastradh Exp $ */
+/* $NetBSD: t_tls_extern.c,v 1.4 2023/06/01 20:50:18 riastradh Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -33,6 +33,87 @@
#define ATF_REQUIRE_DL(x) ATF_REQUIRE_MSG(x, "%s: %s", #x, dlerror())
+ATF_TC(tls_extern_dynamic_defuse);
+ATF_TC_HEAD(tls_extern_dynamic_defuse, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "extern __thread for dynamic TLS works,"
+ " loading def then use");
+}
+ATF_TC_BODY(tls_extern_dynamic_defuse, tc)
+{
+ void *def, *use;
+ int *(*fdef)(void), *(*fuse)(void);
+ int *pdef, *puse;
+
+ (void)dlerror();
+
+ ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0));
+ ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0));
+
+ ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
+ ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
+
+ pdef = (*fdef)();
+ puse = (*fuse)();
+ ATF_CHECK_EQ_MSG(pdef, puse,
+ "%p in defining library != %p in using library",
+ pdef, puse);
+}
+
+ATF_TC(tls_extern_dynamic_usedef);
+ATF_TC_HEAD(tls_extern_dynamic_usedef, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "extern __thread for dynamic TLS works,"
+ " loading use then def");
+}
+ATF_TC_BODY(tls_extern_dynamic_usedef, tc)
+{
+ void *def, *use;
+ int *(*fdef)(void), *(*fuse)(void);
+ int *pdef, *puse;
+
+ (void)dlerror();
+
+ ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0));
+ ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0));
+
+ ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
+ ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
+
+ pdef = (*fdef)();
+ puse = (*fuse)();
+ ATF_CHECK_EQ_MSG(pdef, puse,
+ "%p in defining library != %p in using library",
+ pdef, puse);
+}
+
+ATF_TC(tls_extern_dynamic_usedefnoload);
+ATF_TC_HEAD(tls_extern_dynamic_usedefnoload, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "extern __thread for dynamic TLS works,"
+ " loading use then def with RTLD_NOLOAD");
+}
+ATF_TC_BODY(tls_extern_dynamic_usedefnoload, tc)
+{
+ void *def, *use;
+ int *(*fdef)(void), *(*fuse)(void);
+ int *pdef, *puse;
+
+ (void)dlerror();
+
+ ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0));
+ ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", RTLD_NOLOAD));
+
+ ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
+ ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
+
+ pdef = (*fdef)();
+ puse = (*fuse)();
+ ATF_CHECK_EQ_MSG(pdef, puse,
+ "%p in defining library != %p in using library",
+ pdef, puse);
+}
+
ATF_TC(tls_extern_static_defuse);
ATF_TC_HEAD(tls_extern_static_defuse, tc)
{
@@ -121,6 +202,9 @@ ATF_TC_BODY(tls_extern_static_usedefnolo
ATF_TP_ADD_TCS(tp)
{
+ ATF_TP_ADD_TC(tp, tls_extern_dynamic_defuse);
+ ATF_TP_ADD_TC(tp, tls_extern_dynamic_usedef);
+ ATF_TP_ADD_TC(tp, tls_extern_dynamic_usedefnoload);
ATF_TP_ADD_TC(tp, tls_extern_static_defuse);
ATF_TP_ADD_TC(tp, tls_extern_static_usedef);
ATF_TP_ADD_TC(tp, tls_extern_static_usedefnoload);
Added files:
Index: src/tests/libexec/ld.elf_so/helper_def_dynamic/Makefile
diff -u /dev/null src/tests/libexec/ld.elf_so/helper_def_dynamic/Makefile:1.1
--- /dev/null Thu Jun 1 20:50:19 2023
+++ src/tests/libexec/ld.elf_so/helper_def_dynamic/Makefile Thu Jun 1 20:50:18 2023
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1 2023/06/01 20:50:18 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_def_dynamic
+SRCS= h_def_dynamic.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>
Index: src/tests/libexec/ld.elf_so/helper_def_dynamic/h_def_dynamic.c
diff -u /dev/null src/tests/libexec/ld.elf_so/helper_def_dynamic/h_def_dynamic.c:1.1
--- /dev/null Thu Jun 1 20:50:19 2023
+++ src/tests/libexec/ld.elf_so/helper_def_dynamic/h_def_dynamic.c Thu Jun 1 20:50:18 2023
@@ -0,0 +1,37 @@
+/* $NetBSD: h_def_dynamic.c,v 1.1 2023/06/01 20:50:18 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 mydynsym = 0;
+
+int *fdef(void);
+int *
+fdef(void)
+{
+
+ return &mydynsym;
+}
Index: src/tests/libexec/ld.elf_so/helper_use_dynamic/Makefile
diff -u /dev/null src/tests/libexec/ld.elf_so/helper_use_dynamic/Makefile:1.1
--- /dev/null Thu Jun 1 20:50:19 2023
+++ src/tests/libexec/ld.elf_so/helper_use_dynamic/Makefile Thu Jun 1 20:50:19 2023
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1 2023/06/01 20:50:19 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_use_dynamic
+SRCS= h_use_dynamic.c
+
+DEF_DIR!= cd ${.CURDIR}/../helper_def_dynamic && ${PRINTOBJDIR}
+LDADD+= -Wl,-rpath,${TESTSDIR} -L${DEF_DIR} -lh_def_dynamic
+
+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>
Index: src/tests/libexec/ld.elf_so/helper_use_dynamic/h_use_dynamic.c
diff -u /dev/null src/tests/libexec/ld.elf_so/helper_use_dynamic/h_use_dynamic.c:1.1
--- /dev/null Thu Jun 1 20:50:19 2023
+++ src/tests/libexec/ld.elf_so/helper_use_dynamic/h_use_dynamic.c Thu Jun 1 20:50:19 2023
@@ -0,0 +1,37 @@
+/* $NetBSD: h_use_dynamic.c,v 1.1 2023/06/01 20:50:19 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.
+ */
+
+extern __thread int mydynsym;
+
+int *fuse(void);
+int *
+fuse(void)
+{
+
+ return &mydynsym;
+}