Module Name: src Committed By: riastradh Date: Thu Jun 1 20:48:30 UTC 2023
Modified Files: src/tests/libexec/ld.elf_so: t_tls_extern.c Log Message: ld.elf_so: Test variations on PR toolchain/50277. XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/libexec/ld.elf_so/t_tls_extern.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/libexec/ld.elf_so/t_tls_extern.c diff -u src/tests/libexec/ld.elf_so/t_tls_extern.c:1.2 src/tests/libexec/ld.elf_so/t_tls_extern.c:1.3 --- src/tests/libexec/ld.elf_so/t_tls_extern.c:1.2 Wed May 31 00:46:11 2023 +++ src/tests/libexec/ld.elf_so/t_tls_extern.c Thu Jun 1 20:48:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_tls_extern.c,v 1.2 2023/05/31 00:46:11 riastradh Exp $ */ +/* $NetBSD: t_tls_extern.c,v 1.3 2023/06/01 20:48:30 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -33,20 +33,79 @@ #define ATF_REQUIRE_DL(x) ATF_REQUIRE_MSG(x, "%s: %s", #x, dlerror()) -ATF_TC(tls_extern_static); -ATF_TC_HEAD(tls_extern_static, tc) +ATF_TC(tls_extern_static_defuse); +ATF_TC_HEAD(tls_extern_static_defuse, tc) { - atf_tc_set_md_var(tc, "descr", "extern __thread for static TLS works"); + atf_tc_set_md_var(tc, "descr", "extern __thread for static TLS works," + " loading def then use"); } -ATF_TC_BODY(tls_extern_static, tc) +ATF_TC_BODY(tls_extern_static_defuse, tc) { void *def, *use; int *(*fdef)(void), *(*fuse)(void); int *pdef, *puse; (void)dlerror(); + + ATF_REQUIRE_DL(def = dlopen("libh_def_static.so", 0)); + ATF_REQUIRE_DL(use = dlopen("libh_use_static.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_static_usedef); +ATF_TC_HEAD(tls_extern_static_usedef, tc) +{ + atf_tc_set_md_var(tc, "descr", "extern __thread for static TLS works," + " loading use then def"); +} +ATF_TC_BODY(tls_extern_static_usedef, tc) +{ + void *def, *use; + int *(*fdef)(void), *(*fuse)(void); + int *pdef, *puse; + + (void)dlerror(); + + ATF_REQUIRE_DL(use = dlopen("libh_use_static.so", 0)); + ATF_REQUIRE_DL(def = dlopen("libh_def_static.so", 0)); + + ATF_REQUIRE_DL(fdef = dlsym(def, "fdef")); + ATF_REQUIRE_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_TC(tls_extern_static_usedefnoload); +ATF_TC_HEAD(tls_extern_static_usedefnoload, tc) +{ + atf_tc_set_md_var(tc, "descr", "extern __thread for static TLS works," + " loading use then def with RTLD_NOLOAD"); +} +ATF_TC_BODY(tls_extern_static_usedefnoload, tc) +{ + void *def, *use; + int *(*fdef)(void), *(*fuse)(void); + int *pdef, *puse; + + (void)dlerror(); + ATF_REQUIRE_DL(use = dlopen("libh_use_static.so", 0)); ATF_REQUIRE_DL(def = dlopen("libh_def_static.so", RTLD_NOLOAD)); + ATF_REQUIRE_DL(fdef = dlsym(def, "fdef")); ATF_REQUIRE_DL(fuse = dlsym(use, "fuse")); @@ -61,6 +120,9 @@ ATF_TC_BODY(tls_extern_static, tc) ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, tls_extern_static); + + 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); return atf_no_error(); }