Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src ld.elf_so: Test another edge case of mismatched TLS models.
details: https://anonhg.NetBSD.org/src/rev/67b2283af2d6
branches: trunk
changeset: 376137:67b2283af2d6
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Jun 02 19:08:48 2023 +0000
description:
ld.elf_so: Test another edge case of mismatched TLS models.
One library defines a symbol and _doesn't_ use it, so it has no
indication of whether the symbol is for static TLS or dynamic TLS,
and then two other libraries use it in different ways.
XXX pullup-10
diffstat:
distrib/sets/lists/debug/shl.mi | 5 +-
distrib/sets/lists/tests/shl.mi | 8 +-
tests/libexec/ld.elf_so/Makefile | 5 +-
tests/libexec/ld.elf_so/helper_onlydef/Makefile | 19 +
tests/libexec/ld.elf_so/helper_onlydef/h_onlydef.c | 29 ++
tests/libexec/ld.elf_so/helper_onlydef_static/Makefile | 19 +
tests/libexec/ld.elf_so/helper_onlydef_static/h_onlydef_static.c | 29 ++
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile | 22 ++
tests/libexec/ld.elf_so/helper_onlyuse_dynamic/h_onlyuse_dynamic.c | 37 +++
tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile | 22 ++
tests/libexec/ld.elf_so/helper_onlyuse_static/h_onlyuse_static.c | 37 +++
tests/libexec/ld.elf_so/t_tls_extern.c | 103 +++++++++-
12 files changed, 331 insertions(+), 4 deletions(-)
diffs (truncated from 433 to 300 lines):
diff -r ca8daf45e6da -r 67b2283af2d6 distrib/sets/lists/debug/shl.mi
--- a/distrib/sets/lists/debug/shl.mi Fri Jun 02 19:08:01 2023 +0000
+++ b/distrib/sets/lists/debug/shl.mi Fri Jun 02 19:08:48 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.308 2023/06/02 12:08:26 riastradh Exp $
+# $NetBSD: shl.mi,v 1.309 2023/06/02 19:08:48 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
@@ -371,6 +371,9 @@
./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_onlydef.so.1.debug tests-libexec-debug debug,compattestfile,atf
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_onlyuse_dynamic.so.1.debug tests-libexec-debug debug,compattestfile,atf
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_onlyuse_static.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
diff -r ca8daf45e6da -r 67b2283af2d6 distrib/sets/lists/tests/shl.mi
--- a/distrib/sets/lists/tests/shl.mi Fri Jun 02 19:08:01 2023 +0000
+++ b/distrib/sets/lists/tests/shl.mi Fri Jun 02 19:08:48 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.14 2023/06/01 22:26:40 riastradh Exp $
+# $NetBSD: shl.mi,v 1.15 2023/06/02 19:08:48 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
@@ -32,6 +32,12 @@
./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_onlydef.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_onlydef.so.1 tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_onlyuse_dynamic.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_onlyuse_dynamic.so.1 tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_onlyuse_static.so tests-libexec-tests compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_onlyuse_static.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
diff -r ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/Makefile
--- a/tests/libexec/ld.elf_so/Makefile Fri Jun 02 19:08:01 2023 +0000
+++ b/tests/libexec/ld.elf_so/Makefile Fri Jun 02 19:08:48 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2023/06/01 22:26:40 riastradh Exp $
+# $NetBSD: Makefile,v 1.18 2023/06/02 19:08:48 riastradh Exp $
#
NOMAN= # defined
@@ -15,9 +15,12 @@ SUBDIR+= helper_dso1 helper_dso3 .WAIT h
SUBDIR+= helper_def_dynamic
SUBDIR+= helper_def_static
+SUBDIR+= helper_onlydef
SUBDIR+= .WAIT
SUBDIR+= helper_abuse_dynamic
SUBDIR+= helper_abuse_static
+SUBDIR+= helper_onlyuse_dynamic
+SUBDIR+= helper_onlyuse_static
SUBDIR+= helper_use_dynamic
SUBDIR+= helper_use_static
diff -r ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlydef/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlydef/Makefile Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1 2023/06/02 19:08:49 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_onlydef
+SRCS= h_onlydef.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 ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlydef/h_onlydef.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlydef/h_onlydef.c Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,29 @@
+/* $NetBSD: h_onlydef.c,v 1.1 2023/06/02 19:08:49 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 = 0;
diff -r ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlydef_static/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlydef_static/Makefile Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1 2023/06/02 19:08:49 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_onlydef_static
+SRCS= h_onlydef_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 ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlydef_static/h_onlydef_static.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlydef_static/h_onlydef_static.c Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,29 @@
+/* $NetBSD: h_onlydef_static.c,v 1.1 2023/06/02 19:08:49 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;
diff -r ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlyuse_dynamic/Makefile Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1 2023/06/02 19:08:49 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_onlyuse_dynamic
+SRCS= h_onlyuse_dynamic.c
+
+DEF_DIR!= cd ${.CURDIR}/../helper_onlydef && ${PRINTOBJDIR}
+LDADD+= -Wl,-rpath,${TESTSDIR} -L${DEF_DIR} -lh_onlydef
+
+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 ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlyuse_dynamic/h_onlyuse_dynamic.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlyuse_dynamic/h_onlyuse_dynamic.c Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,37 @@
+/* $NetBSD: h_onlyuse_dynamic.c,v 1.1 2023/06/02 19:08:49 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 mysym; /* dynamic */
+
+int *fdynamic(void);
+int *
+fdynamic(void)
+{
+
+ return &mysym;
+}
diff -r ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlyuse_static/Makefile Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1 2023/06/02 19:08:49 riastradh Exp $
+
+.include <bsd.own.mk>
+
+LIB= h_onlyuse_static
+SRCS= h_onlyuse_static.c
+
+DEF_DIR!= cd ${.CURDIR}/../helper_onlydef && ${PRINTOBJDIR}
+LDADD+= -Wl,-rpath,${TESTSDIR} -L${DEF_DIR} -lh_onlydef
+
+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 ca8daf45e6da -r 67b2283af2d6 tests/libexec/ld.elf_so/helper_onlyuse_static/h_onlyuse_static.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libexec/ld.elf_so/helper_onlyuse_static/h_onlyuse_static.c Fri Jun 02 19:08:48 2023 +0000
@@ -0,0 +1,37 @@
+/* $NetBSD: h_onlyuse_static.c,v 1.1 2023/06/02 19:08:49 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.
+ */
+
Home |
Main Index |
Thread Index |
Old Index