Module Name: src Committed By: riastradh Date: Wed May 31 00:18:44 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi shl.mi src/tests/libexec/ld.elf_so: Makefile Added Files: src/tests/libexec/ld.elf_so: t_tls_extern.c src/tests/libexec/ld.elf_so/helper_def_static: Makefile h_def_static.c src/tests/libexec/ld.elf_so/helper_use_static: Makefile h_use_static.c Log Message: ld.elf_so: New test for extern initial-exec TLS, PR toolchain/50277. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.1264 -r1.1265 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.11 -r1.12 src/distrib/sets/lists/tests/shl.mi cvs rdiff -u -r1.12 -r1.13 src/tests/libexec/ld.elf_so/Makefile cvs rdiff -u -r0 -r1.1 src/tests/libexec/ld.elf_so/t_tls_extern.c cvs rdiff -u -r0 -r1.1 src/tests/libexec/ld.elf_so/helper_def_static/Makefile \ src/tests/libexec/ld.elf_so/helper_def_static/h_def_static.c cvs rdiff -u -r0 -r1.1 src/tests/libexec/ld.elf_so/helper_use_static/Makefile \ src/tests/libexec/ld.elf_so/helper_use_static/h_use_static.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/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1264 src/distrib/sets/lists/tests/mi:1.1265 --- src/distrib/sets/lists/tests/mi:1.1264 Sat May 20 21:32:05 2023 +++ src/distrib/sets/lists/tests/mi Wed May 31 00:18:44 2023 @@ -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 Index: src/distrib/sets/lists/tests/shl.mi diff -u src/distrib/sets/lists/tests/shl.mi:1.11 src/distrib/sets/lists/tests/shl.mi:1.12 --- src/distrib/sets/lists/tests/shl.mi:1.11 Tue Jul 11 15:21:32 2017 +++ src/distrib/sets/lists/tests/shl.mi Wed May 31 00:18:44 2023 @@ -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 Index: src/tests/libexec/ld.elf_so/Makefile diff -u src/tests/libexec/ld.elf_so/Makefile:1.12 src/tests/libexec/ld.elf_so/Makefile:1.13 --- src/tests/libexec/ld.elf_so/Makefile:1.12 Sun May 30 02:26:51 2021 +++ src/tests/libexec/ld.elf_so/Makefile Wed May 31 00:18:44 2023 @@ -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 Added files: Index: src/tests/libexec/ld.elf_so/t_tls_extern.c diff -u /dev/null src/tests/libexec/ld.elf_so/t_tls_extern.c:1.1 --- /dev/null Wed May 31 00:18:44 2023 +++ src/tests/libexec/ld.elf_so/t_tls_extern.c Wed May 31 00:18:44 2023 @@ -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(); +} Index: src/tests/libexec/ld.elf_so/helper_def_static/Makefile diff -u /dev/null src/tests/libexec/ld.elf_so/helper_def_static/Makefile:1.1 --- /dev/null Wed May 31 00:18:44 2023 +++ src/tests/libexec/ld.elf_so/helper_def_static/Makefile Wed May 31 00:18:44 2023 @@ -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> Index: src/tests/libexec/ld.elf_so/helper_def_static/h_def_static.c diff -u /dev/null src/tests/libexec/ld.elf_so/helper_def_static/h_def_static.c:1.1 --- /dev/null Wed May 31 00:18:44 2023 +++ src/tests/libexec/ld.elf_so/helper_def_static/h_def_static.c Wed May 31 00:18:44 2023 @@ -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; +} Index: src/tests/libexec/ld.elf_so/helper_use_static/Makefile diff -u /dev/null src/tests/libexec/ld.elf_so/helper_use_static/Makefile:1.1 --- /dev/null Wed May 31 00:18:44 2023 +++ src/tests/libexec/ld.elf_so/helper_use_static/Makefile Wed May 31 00:18:44 2023 @@ -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> Index: src/tests/libexec/ld.elf_so/helper_use_static/h_use_static.c diff -u /dev/null src/tests/libexec/ld.elf_so/helper_use_static/h_use_static.c:1.1 --- /dev/null Wed May 31 00:18:44 2023 +++ src/tests/libexec/ld.elf_so/helper_use_static/h_use_static.c Wed May 31 00:18:44 2023 @@ -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; +}