ld.elf_so: Test extern dynamic TLS too.

XXX pullup-10
This commit is contained in:
riastradh 2023-06-01 20:50:18 +00:00
parent f4e155a450
commit 05e97b5a42
8 changed files with 211 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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 helper_dso2 .WAIT \
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

View File

@ -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>

View File

@ -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;
}

View File

@ -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>

View File

@ -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;
}

View File

@ -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_usedefnoload, tc)
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);