From patchwork Sat Mar 16 22:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1912827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=exRQjQwr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Txw6j37pBz1yWv for ; Sun, 17 Mar 2024 09:01:00 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 447613858410 for ; Sat, 16 Mar 2024 22:00:57 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 5507F3858D20 for ; Sat, 16 Mar 2024 22:00:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5507F3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5507F3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710626441; cv=none; b=uByJClaNfmCrCb8ZFJojA3U/DJ9YTEYY4wTJGbVivDCNTz7dbavuuDpeFNJnUbjbXrKwnKBAZbPZ3YTv30yrCxctrpu2jgxqTDwSlCArdcJQFfXWxObZUnpGyb+fDhkZSZrIOzc03wfa/cInJwdBEKWVRRpbqx9ExzhtErKw2wA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710626441; c=relaxed/simple; bh=dQsbYIg5BgrL8eaSTqdNR3xLeBY2lYgMli3FWVPbFDQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LUBfllBHV0wVP7/ztXJKfGrTjFFZ1B+bZ3nEOhnrA976rkHx/R4jeRrqkZeSa2JjQmuKxmDW94NzGXS+cMKIc54jHOUAGLjWiem/I/yzPaimHzOzmzhyWL0MNAEHa33BjwxfJFq7udJp41zRZmsTIWc203Bbpb8TgTccv/J98nQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dc3b4b9b62so21781895ad.1 for ; Sat, 16 Mar 2024 15:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710626437; x=1711231237; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AXdZbdx+t3NtjCSIHQznwAqJh2Xc4uyEQQ5TfTS511c=; b=exRQjQwr63i8XCSiBmP8ErS+IMInN6udrxQsfHeQD+26SyCpVMxZWIvkZy60gPYdr2 McA/Ba0ZtqPiwKO8U72KzJVadKO91/JfTnJrDXjLG1oVmPBRBESAXpej2wXqH4c+I36Z HHV+b1HTEL/jHch0mPssGcSE8C85QkWGPXw3+QhMK2cLaIx0FQrTv0p1owFjQgOGkQhn qeSIZZ6y4aG7cCwwajS4Tovv8qZSihDl1Z5MtlDJkaFNs7UVwcoO+wrTXJMCN85/rS/o V5ijWPaG+L4+4ULP/5jQB+5gFioKq7nqLJSGnh9e6JOjw1ucIqyYdi1XSUBd+1MkrQls Ylcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710626437; x=1711231237; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AXdZbdx+t3NtjCSIHQznwAqJh2Xc4uyEQQ5TfTS511c=; b=rM1Zy5USaasX4Y/fDEJuzSp18bRz3zOBhvzPn2ju+BBA81y28TQoUmuN+ZIMJGZSbr UvLKmgKJR1LLfBsOingdyAKcU+MplBz+Cs5WcpK5PUjCa1g9F7cpKW/1dy1I2zrgSi+v hY11vAH2NEhNjGCnQlF4fSzKv2AnzrY/9RuAdlhHuBF0z0oJaT1LOKprj7H4QqZqx/sq 0+PxZapJVYNS2SSFLleOEE1FMknB4b0crjwTkX7JkvGezX3/rqQ4zgUl9PlbL5SV0/SW Kb4Qfr694HbPMEqv4cd3xi4yBUvi3FFWLMyxTSYNqO/pOQHe1xBPs8MTRR51HbYk4odH ZJcw== X-Gm-Message-State: AOJu0YytYoMmQbu9d7s2iDmn4uGwHgOnUtf4RzDdKgmjgAOxC/jbja1t JyySvT/ck2aMrlRI41i9I6B9j1fQBH+bT1rOTXuBfuUD+rNMyo34PDCqOrCa X-Google-Smtp-Source: AGHT+IHvWGHegWdRPWZyPnRul60Zvx4YX6nm6CJbICBzkv/UfTU5NMhfRz4klxG5zd6cGUM5XIp32g== X-Received: by 2002:a17:902:da88:b0:1dd:d869:a237 with SMTP id j8-20020a170902da8800b001ddd869a237mr15081207plx.34.1710626436924; Sat, 16 Mar 2024 15:00:36 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.58.89.72]) by smtp.gmail.com with ESMTPSA id li8-20020a170903294800b001dd7321036csm6252939plb.195.2024.03.16.15.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Mar 2024 15:00:36 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 02CE9740639; Sat, 16 Mar 2024 15:00:35 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH] x86-64: Allocate state buffer space for RDI, RSI and RBX Date: Sat, 16 Mar 2024 15:00:34 -0700 Message-ID: <20240316220034.512517-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3019.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning stack. After realigning stack, it saves RCX, RDX, R8, R9, R10 and R11. Define TLSDESC_CALL_STATE_SAVE_OFFSET to allocate space for all integer registers and round up the state size to 64 bytes to avoid clobbering saved RDI, RSI and RBX values on stack by xsave to STATE_SAVE_OFFSET(%rsp). This fixes BZ #31501. --- sysdeps/x86/cpu-features.c | 11 +- sysdeps/x86/sysdep.h | 8 ++ sysdeps/x86_64/Makefile | 19 ++++ sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod0.c | 31 +++++ sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod1.S | 77 +++++++++++++ sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod2.c | 31 +++++ sysdeps/x86_64/tst-gnu2-tls2-x86-64.c | 126 +++++++++++++++++++++ sysdeps/x86_64/tst-gnu2-tls2-x86-64.h | 36 ++++++ 8 files changed, 335 insertions(+), 4 deletions(-) create mode 100644 sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod0.c create mode 100644 sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod1.S create mode 100644 sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod2.c create mode 100644 sysdeps/x86_64/tst-gnu2-tls2-x86-64.c create mode 100644 sysdeps/x86_64/tst-gnu2-tls2-x86-64.h diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 4ea373dffa..5e9c167417 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -311,7 +311,7 @@ update_active (struct cpu_features *cpu_features) /* NB: On AMX capable processors, ebx always includes AMX states. */ unsigned int xsave_state_full_size - = ALIGN_UP (ebx + STATE_SAVE_OFFSET, 64); + = ALIGN_UP (ebx + TLSDESC_CALL_STATE_SAVE_OFFSET, 64); cpu_features->xsave_state_size = xsave_state_full_size; @@ -401,8 +401,10 @@ update_active (struct cpu_features *cpu_features) unsigned int amx_size = (xstate_amx_comp_offsets[31] + xstate_amx_comp_sizes[31]); - amx_size = ALIGN_UP (amx_size + STATE_SAVE_OFFSET, - 64); + amx_size + = ALIGN_UP ((amx_size + + TLSDESC_CALL_STATE_SAVE_OFFSET), + 64); /* Set xsave_state_full_size to the compact AMX state size for XSAVEC. NB: xsave_state_full_size is only used in _dl_tlsdesc_dynamic_xsave and @@ -410,7 +412,8 @@ update_active (struct cpu_features *cpu_features) cpu_features->xsave_state_full_size = amx_size; #endif cpu_features->xsave_state_size - = ALIGN_UP (size + STATE_SAVE_OFFSET, 64); + = ALIGN_UP (size + TLSDESC_CALL_STATE_SAVE_OFFSET, + 64); CPU_FEATURE_SET (cpu_features, XSAVEC); } } diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h index db8e576e91..262d4083e2 100644 --- a/sysdeps/x86/sysdep.h +++ b/sysdeps/x86/sysdep.h @@ -46,6 +46,13 @@ red-zone into account. */ # define STATE_SAVE_OFFSET (8 * 7 + 8) +/* _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning + stack. After realigning stack, it saves RCX, RDX, R8, R9, R10 and + R11. Allocate space for all integer registers and round up the state + size to 64 bytes to avoid clobbering saved RDI, RSI and RBX values on + stack by xsave on STATE_SAVE_OFFSET(%rsp). */ +# define TLSDESC_CALL_STATE_SAVE_OFFSET (STATE_SAVE_OFFSET + 64) + /* Save SSE, AVX, AVX512, mask, bound and APX registers. Bound and APX registers are mutually exclusive. */ # define STATE_SAVE_MASK \ @@ -68,6 +75,7 @@ /* Offset for fxsave/xsave area used by _dl_tlsdesc_dynamic. Since i386 doesn't have red-zone, use 0 here. */ # define STATE_SAVE_OFFSET 0 +# define TLSDESC_CALL_STATE_SAVE_OFFSET 0 /* Save SSE, AVX, AXV512, mask and bound registers. */ # define STATE_SAVE_MASK \ diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index 66b21954f3..e21e4b96ab 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -217,6 +217,25 @@ valgrind-suppressions-tst-valgrind-smoke = \ --suppressions=$(..)sysdeps/x86_64/tst-valgrind-smoke.supp endif +tests += \ + tst-gnu2-tls2-x86-64 \ +# tests + +modules-names += \ + tst-gnu2-tls2-x86-64-mod0 \ + tst-gnu2-tls2-x86-64-mod1 \ + tst-gnu2-tls2-x86-64-mod2 \ +# modules-names + +$(objpfx)tst-gnu2-tls2-x86-64: $(shared-thread-library) +$(objpfx)tst-gnu2-tls2-x86-64.out: \ + $(objpfx)tst-gnu2-tls2-x86-64-mod0.so \ + $(objpfx)tst-gnu2-tls2-x86-64-mod1.so \ + $(objpfx)tst-gnu2-tls2-x86-64-mod2.so + +CFLAGS-tst-gnu2-tls2-x86-64-mod0.c += -mtls-dialect=gnu2 +CFLAGS-tst-gnu2-tls2-x86-64-mod2.c += -mtls-dialect=gnu2 + endif # $(subdir) == elf ifeq ($(subdir),csu) diff --git a/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod0.c b/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod0.c new file mode 100644 index 0000000000..496ad0767f --- /dev/null +++ b/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod0.c @@ -0,0 +1,31 @@ +/* DSO used by tst-gnu2-tls2-x86-64. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-gnu2-tls2-x86-64.h" + +__thread struct tls tls_var0 __attribute__ ((visibility ("hidden"))); + +struct tls * +apply_tls (struct tls *p, intptr_t offset) +{ + BEFORE_TLSDESC_CALL (); + tls_var0 = *p; + struct tls *ret = &tls_var0; + AFTER_TLSDESC_CALL (); + return ret; +} diff --git a/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod1.S b/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod1.S new file mode 100644 index 0000000000..7a9b5766cf --- /dev/null +++ b/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod1.S @@ -0,0 +1,77 @@ +/* Check if TLSDESC relocation preserves %rdi, %rsi and %rbx. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + + .text + .p2align 4 + .globl apply_tls + .type apply_tls, @function +apply_tls: + cfi_startproc + _CET_ENDBR + pushq %rbp + cfi_def_cfa_offset (16) + cfi_offset (6, -16) + movdqu (%RDI_LP), %xmm0 + lea tls_var1@TLSDESC(%rip), %RAX_LP + mov %RSP_LP, %RBP_LP + cfi_def_cfa_register (6) + /* Align stack to 64 bytes. */ + and $-64, %RSP_LP + sub %RSI_LP, %RSP_LP + pushq %rbx + /* Set %ebx to 0xbadbeef. */ + movl $0xbadbeef, %ebx + movq %rdi, saved_rdi(%rip) + movq %rsi, saved_rsi(%rip) + call *tls_var1@TLSCALL(%RAX_LP) + /* Check if _dl_tlsdesc_dynamic preserves %rdi, %rsi and %rbx. */ + cmpq saved_rdi(%rip), %rdi + jne L(hlt) + cmpq saved_rsi(%rip), %rsi + jne L(hlt) + cmpl $0xbadbeef, %ebx + jne L(hlt) + add %fs:0, %RAX_LP + movups %xmm0, 32(%RAX_LP) + movdqu 16(%RDI_LP), %xmm1 + mov %RAX_LP, %RBX_LP + movups %xmm1, 48(%RAX_LP) + lea 32(%RBX_LP), %RAX_LP + pop %rbx + leave + cfi_def_cfa (7, 8) + ret +L(hlt): + hlt + cfi_endproc + .size apply_tls, .-apply_tls + .hidden tls_var1 + .globl tls_var1 + .section .tbss,"awT",@nobits + .align 16 + .type tls_var1, @object + .size tls_var1, 3200 +tls_var1: + .zero 3200 + .local saved_rdi + .comm saved_rdi,8,8 + .local saved_rsi + .comm saved_rsi,8,8 + .section .note.GNU-stack,"",@progbits diff --git a/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod2.c b/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod2.c new file mode 100644 index 0000000000..632a8dce80 --- /dev/null +++ b/sysdeps/x86_64/tst-gnu2-tls2-x86-64-mod2.c @@ -0,0 +1,31 @@ +/* DSO used by tst-gnu2-tls2-x86-64. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-gnu2-tls2-x86-64.h" + +__thread struct tls tls_var2 __attribute__ ((visibility ("hidden"))); + +struct tls * +apply_tls (struct tls *p, intptr_t offset) +{ + BEFORE_TLSDESC_CALL (); + tls_var2 = *p; + struct tls *ret = &tls_var2; + AFTER_TLSDESC_CALL (); + return ret; +} diff --git a/sysdeps/x86_64/tst-gnu2-tls2-x86-64.c b/sysdeps/x86_64/tst-gnu2-tls2-x86-64.c new file mode 100644 index 0000000000..acb38a66c1 --- /dev/null +++ b/sysdeps/x86_64/tst-gnu2-tls2-x86-64.c @@ -0,0 +1,126 @@ +/* Check if TLSDESC relocation preserves %rdi, %rsi and %rbx. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tst-gnu2-tls2-x86-64.h" + +#ifndef IS_SUPPORTED +# define IS_SUPPORTED() true +#endif + +/* An architecture can define it to clobber caller-saved registers in + malloc below to verify that the implicit TLSDESC call won't change + caller-saved registers. */ +#ifndef PREPARE_MALLOC +# define PREPARE_MALLOC() +#endif + +extern void * __libc_malloc (size_t); + +size_t malloc_counter = 0; + +void * +malloc (size_t n) +{ + PREPARE_MALLOC (); + malloc_counter++; + return __libc_malloc (n); +} + +static void *mod[3]; +#ifndef MOD +# define MOD(i) "tst-gnu2-tls2-x86-64-mod" #i ".so" +#endif +static const char *modname[3] = { MOD(0), MOD(1), MOD(2) }; +#undef MOD + +static void +open_mod (int i) +{ + mod[i] = xdlopen (modname[i], RTLD_LAZY); + printf ("open %s\n", modname[i]); +} + +static void +close_mod (int i) +{ + xdlclose (mod[i]); + mod[i] = NULL; + printf ("close %s\n", modname[i]); +} + +static void +access_mod (int i, const char *sym) +{ + struct tls var = { -1, -1, -1, -1 }; + struct tls *(*f) (struct tls *, intptr_t) = xdlsym (mod[i], sym); + /* Check that our malloc is called. */ + malloc_counter = 0; + /* apply_tls will align stack to 64 bytes and adjust stack by OFFSET + and followed by "pushq %rbx". On AVX512 machines, OFFSET == 104 + causes _dl_tlsdesc_dynamic_xsavec to clobber %rdi, %rsi and %rbx. */ + intptr_t offset = 104; + struct tls *p = f (&var, offset); + TEST_VERIFY (malloc_counter != 0); + printf ("access %s: %s() = %p\n", modname[i], sym, p); + TEST_VERIFY_EXIT (memcmp (p, &var, sizeof (var)) == 0); + ++(p->a); +} + +static void * +start (void *arg) +{ + /* The DTV generation is at the last dlopen of mod0 and the + entry for mod1 is NULL. */ + + open_mod (1); /* Reuse modid of mod1. Uses dynamic TLS. */ + + /* Force the slow path in GNU2 TLS descriptor call. */ + access_mod (1, "apply_tls"); + + return arg; +} + +static int +do_test (void) +{ + if (!IS_SUPPORTED ()) + return EXIT_UNSUPPORTED; + + open_mod (0); + open_mod (1); + open_mod (2); + close_mod (0); + close_mod (1); /* Create modid gap at mod1. */ + open_mod (0); /* Reuse modid of mod0, bump generation count. */ + + /* Create a thread where DTV of mod1 is NULL. */ + pthread_t t = xpthread_create (NULL, start, NULL); + xpthread_join (t); + return 0; +} + +#include diff --git a/sysdeps/x86_64/tst-gnu2-tls2-x86-64.h b/sysdeps/x86_64/tst-gnu2-tls2-x86-64.h new file mode 100644 index 0000000000..16055c77aa --- /dev/null +++ b/sysdeps/x86_64/tst-gnu2-tls2-x86-64.h @@ -0,0 +1,36 @@ +/* Test TLSDESC relocation. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +struct tls +{ + int64_t a, b, c, d; +}; + +extern struct tls *apply_tls (struct tls *, intptr_t); + +/* An architecture can define them to verify that clobber caller-saved + registers aren't changed by the implicit TLSDESC call. */ +#ifndef BEFORE_TLSDESC_CALL +# define BEFORE_TLSDESC_CALL() +#endif + +#ifndef AFTER_TLSDESC_CALL +# define AFTER_TLSDESC_CALL() +#endif