From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by sourceware.org (Postfix) with ESMTPS id 96FB23858D20 for ; Wed, 13 Sep 2023 19:07:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 96FB23858D20 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-59bd2e19c95so1994087b3.0 for ; Wed, 13 Sep 2023 12:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1694632070; x=1695236870; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Uwz1YctDrJSfEh6LrB0WDVmqQ1PhW23V47OKI1LAi74=; b=J8BCfY0gRHpSxUPdaDcowRkhudhfEZH8fqT4mBK5P2zP3AjqI8+1do2byDmk2H7oKC MxVyUmJUjhcqBfDlM0UYu1/AtD49JZhytypnEZirgs0XXq2NXQQp8fWZp7j0tNTtYBtn nuX0ncxd1WkheuWst30GRRZSQE5Kyb6h0HohMIGKXy7ZYOsKdUMqoG7WKQdgnPzPml1r fE2FDzqPjE6HnEYEHYCIwwNmwc3dkA+nTraylJzIkBQEFyH/Pi40XmHD9ecRGdL9Z9VP PcICYktNeGe1sKXY/2eZ/NKiWjEzCdE+seSS30y0a6ljhlL3RQFb8z5CcOh6XbotiS4t qxXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694632070; x=1695236870; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uwz1YctDrJSfEh6LrB0WDVmqQ1PhW23V47OKI1LAi74=; b=duhb0RarfD6DgFiLgYTZoxt+mhsuc2rtHLIKHBwTp69+GZvexMlhkQAcUhJusEIN3d sDLVAEqKO6FI+d0uQLv/PIyonxT6HYPK+Kon9WmNKSCRIb7QvWZbEDZIikGN3t/qOFp6 5NLCgB/PdM3923dXIDWvs0J3tNYOq5TVGeA59tvPZ494fal41ofUgvF2SyxN/rcZdkJm YH/JS9lXszXhs/eLHjFNg75ib+uzh3DfBfBAf1gFO3Bsjnzbwnn8qlUIdJtlTninytgU /2KvKf+7IJ5P3PvEE/3z0GLr21i1cj22GozOph84JpVWPK5jJv3Md9R+w7kBrMUd0iGz i9ug== X-Gm-Message-State: AOJu0YxKVdQ7J6cl0ffrJa9IsNf6O34CppyQZddVnadnqd0xrbR2TMUp +kJqjCtVai4JzU8uQGftEDwcuzwQTVfgvlGSVtI56h2x5uLqExx0ok8vpZet05yu2uC6CNuLMK6 59ZuZzj86AIwpyQPSfJokST4W/+sT2iBjgHckNLBQcPZphpGTIPPcXIXdKRREkODgYcmDhsI5xj Lp X-Google-Smtp-Source: AGHT+IEvf2zc13s7gbUQJwgWjHy4wXRvY6+4fz8fR7jS/07/PJxWl+5T6SDcND2jnHKbrzeMPtPNUA== X-Received: by 2002:a0d:d7d1:0:b0:59a:fa28:2b98 with SMTP id z200-20020a0dd7d1000000b0059afa282b98mr3268437ywd.17.1694632070391; Wed, 13 Sep 2023 12:07:50 -0700 (PDT) Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com. [209.85.219.182]) by smtp.gmail.com with ESMTPSA id r19-20020a81c313000000b0059b12808f55sm3243563ywk.49.2023.09.13.12.07.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Sep 2023 12:07:49 -0700 (PDT) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-ccc462deca6so184982276.0 for ; Wed, 13 Sep 2023 12:07:49 -0700 (PDT) X-Received: by 2002:a5b:9cb:0:b0:d78:37f2:86b5 with SMTP id y11-20020a5b09cb000000b00d7837f286b5mr2819077ybq.15.1694632069419; Wed, 13 Sep 2023 12:07:49 -0700 (PDT) MIME-Version: 1.0 References: <20230817181228.122674-2-ishitatsuyuki@gmail.com> In-Reply-To: <20230817181228.122674-2-ishitatsuyuki@gmail.com> From: Andrew Waterman Date: Wed, 13 Sep 2023 12:07:38 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] RISC-V: Implement TLS Descriptors. To: Tatsuyuki Ishi Cc: libc-alpha@sourceware.org, rui314@gmail.com, ruiu@bluewhale.systems Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The 3*SZREG stack-frame size won't maintain the ABI stack alignment; I suggest masking it with ALMASK. On Thu, Aug 17, 2023 at 11:13=E2=80=AFAM Tatsuyuki Ishi via Libc-alpha wrote: > > This is mostly based off AArch64 implementation, with some adaptations > to different TLS DTV offsets and calling conventions. > --- > No regression in binutils and gcc tests for rv64gc, tested alongside the > gcc and binutils implementation (posted at the same time). > > This contribution is made on behalf of Blue Whale Systems, which has > copyright assignment on file with the FSF. > > sysdeps/riscv/Makefile | 8 ++ > sysdeps/riscv/dl-lookupcfg.h | 27 +++++ > sysdeps/riscv/dl-machine.h | 27 +++++ > sysdeps/riscv/dl-tlsdesc.S | 204 +++++++++++++++++++++++++++++++++++ > sysdeps/riscv/dl-tlsdesc.h | 49 +++++++++ > sysdeps/riscv/linkmap.h | 1 + > sysdeps/riscv/tlsdesc.c | 38 +++++++ > sysdeps/riscv/tlsdesc.sym | 19 ++++ > 8 files changed, 373 insertions(+) > create mode 100644 sysdeps/riscv/dl-lookupcfg.h > create mode 100644 sysdeps/riscv/dl-tlsdesc.S > create mode 100644 sysdeps/riscv/dl-tlsdesc.h > create mode 100644 sysdeps/riscv/tlsdesc.c > create mode 100644 sysdeps/riscv/tlsdesc.sym > > diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile > index 8fb10b164f..bb4bcd29b2 100644 > --- a/sysdeps/riscv/Makefile > +++ b/sysdeps/riscv/Makefile > @@ -2,6 +2,14 @@ ifeq ($(subdir),misc) > sysdep_headers +=3D sys/asm.h > endif > > +ifeq ($(subdir),elf) > +sysdep-dl-routines +=3D tlsdesc dl-tlsdesc > +endif > + > +ifeq ($(subdir),csu) > +gen-as-const-headers +=3D tlsdesc.sym > +endif > + > # RISC-V's assembler also needs to know about PIC as it changes the defi= nition > # of some assembler macros. > ASFLAGS-.os +=3D $(pic-ccflag) > diff --git a/sysdeps/riscv/dl-lookupcfg.h b/sysdeps/riscv/dl-lookupcfg.h > new file mode 100644 > index 0000000000..c003a27f63 > --- /dev/null > +++ b/sysdeps/riscv/dl-lookupcfg.h > @@ -0,0 +1,27 @@ > +/* Configuration of lookup functions. > + Copyright (C) 2006-2023 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 > + . */ > + > +#define DL_UNMAP_IS_SPECIAL > + > +#include_next > + > +struct link_map; > + > +extern void _dl_unmap (struct link_map *map); > + > +#define DL_UNMAP(map) _dl_unmap (map) > \ No newline at end of file > diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h > index c0c9bd93ad..ad5b3b20d0 100644 > --- a/sysdeps/riscv/dl-machine.h > +++ b/sysdeps/riscv/dl-machine.h > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -219,6 +220,32 @@ elf_machine_rela (struct link_map *map, struct r_sco= pe_elem *scope[], > } > break; > > + case R_RISCV_TLSDESC: > + struct tlsdesc *td =3D (struct tlsdesc *) addr_field; > + if (sym =3D=3D NULL) > + { > + td->entry =3D _dl_tlsdesc_undefweak; > + td->arg =3D reloc->r_addend; > + } > + else > + { > +# ifndef SHARED > + CHECK_STATIC_TLS (map, sym_map); > +# else > + if (!TRY_STATIC_TLS (map, sym_map)) > + { > + td->entry =3D _dl_tlsdesc_dynamic; > + td->arg =3D _dl_make_tlsdesc_dynamic (sym_map, sym->st_valu= e + reloc->r_addend); > + } > + else > +# endif > + { > + td->entry =3D _dl_tlsdesc_return; > + td->arg =3D (void *)(TLS_TPREL_VALUE(sym_map, sym) + reloc-= >r_addend); > + } > + } > + break; > + > case R_RISCV_COPY: > { > if (__glibc_unlikely (sym =3D=3D NULL)) > diff --git a/sysdeps/riscv/dl-tlsdesc.S b/sysdeps/riscv/dl-tlsdesc.S > new file mode 100644 > index 0000000000..bc48939739 > --- /dev/null > +++ b/sysdeps/riscv/dl-tlsdesc.S > @@ -0,0 +1,204 @@ > +/* Thread-local storage handling in the ELF dynamic linker. > + RISC-V version. > + Copyright (C) 2023 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 > + > +#ifdef __riscv_float_abi_soft > +# define FRAME_SIZE (-((-12 * SZREG) & ALMASK)) > +#else > +# define FRAME_SIZE (-((-12 * SZREG - 20 * SZFREG) & ALMASK)) > +#endif > + > + .text > + > + /* Compute the thread pointer offset for symbols in the static > + TLS block. The offset is the same for all threads. > + Prototype: > + _dl_tlsdesc_return (tlsdesc *) ; > + */ > +ENTRY (_dl_tlsdesc_return) > + REG_L a0, SZREG(a0) > + jr t0 > +END (_dl_tlsdesc_return) > + > + /* Handler for undefined weak TLS symbols. > + Prototype: > + _dl_tlsdesc_undefweak (tlsdesc *); > + > + The second word of the descriptor contains the addend. > + Return the addend minus the thread pointer. This ensures > + that when the caller adds on the thread pointer it gets back > + the addend. */ > + > +ENTRY (_dl_tlsdesc_undefweak) > + REG_L a0, SZREG(a0) > + sub a0, a0, tp > + jr t0 > +END (_dl_tlsdesc_undefweak) > + > +#ifdef SHARED > + /* Handler for dynamic TLS symbols. > + Prototype: > + _dl_tlsdesc_dynamic (tlsdesc *) ; > + > + The second word of the descriptor points to a > + tlsdesc_dynamic_arg structure. > + > + Returns the offset between the thread pointer and the > + object referenced by the argument. > + > + unsigned long > + _dl_tlsdesc_dynamic (struct tlsdesc *tdp) > + { > + struct tlsdesc_dynamic_arg *td =3D tdp->arg; > + dtv_t *dtv =3D *(dtv_t **)((char *)__thread_pointer + TCBHEA= D_DTV); > + if (__builtin_expect (td->gen_count <=3D dtv[0].counter > + && (dtv[td->tlsinfo.ti_module].pointer.val > + !=3D TLS_DTV_UNALLOCATED), > + 1)) > + return dtv[td->tlsinfo.ti_module].pointer.val > + + td->tlsinfo.ti_offset > + - __thread_pointer; > + > + return ___tls_get_addr (&td->tlsinfo) - __thread_pointer; > + } > + */ > + > +ENTRY (_dl_tlsdesc_dynamic) > + /* Save just enough registers to support fast path, if we fall > + into slow path we will save additional registers. */ > + add sp, sp, -3*SZREG > + REG_S t0, 0*SZREG(sp) > + REG_S t1, 1*SZREG(sp) > + REG_S t2, 2*SZREG(sp) > + > + /* t0 =3D dtv */ > + REG_L t0, TCBHEAD_DTV(tp) > + /* a0 =3D tdp->arg */ > + REG_L a0, TLSDESC_ARG(a0) > + /* t1 =3D td->gen_count */ > + REG_L t1, TLSDESC_GEN_COUNT(a0) > + /* t2 =3D dtv[0].counter */ > + REG_L t2, DTV_COUNTER(t0) > + bltu t2, t1, .Lslow > + /* t1 =3D td->tlsinfo.ti_module */ > + REG_L t1, TLSDESC_MODID(a0) > + slli t1, t1, PTRLOG + 1 /* sizeof(dtv_t) =3D=3D sizeof(void*) = * 2 */ > + add t1, t1, t0 > + /* t1 =3D dtv[td->tlsinfo.ti_module].pointer.val */ > + REG_L t1, 0(t1) > + li t2, TLS_DTV_UNALLOCATED > + beq t1, t2, .Lslow > + /* t2 =3D td->tlsinfo.ti_offset */ > + REG_L t2, TLSDESC_MODOFF(a0) > + add a0, t1, t2 > +.Lret: > + sub a0, a0, tp > + REG_L t0, 0*SZREG(sp) > + REG_L t1, 1*SZREG(sp) > + REG_L t2, 2*SZREG(sp) > + add sp, sp, 3*SZREG > + jr t0 > +.Lslow: > + /* This is the slow path. We need to call __tls_get_addr() which > + means we need to save and restore all the register that the > + callee will trash. */ > + > + /* Save the remaining registers that we must treat as caller save= . */ > + addi sp, sp, -FRAME_SIZE > + REG_S ra, 0*SZREG(sp) > + REG_S a1, 1*SZREG(sp) > + REG_S a2, 2*SZREG(sp) > + REG_S a3, 3*SZREG(sp) > + REG_S a4, 4*SZREG(sp) > + REG_S a5, 5*SZREG(sp) > + REG_S a6, 6*SZREG(sp) > + REG_S a7, 7*SZREG(sp) > + REG_S t3, 8*SZREG(sp) > + REG_S t4, 9*SZREG(sp) > + REG_S t5, 10*SZREG(sp) > + REG_S t6, 11*SZREG(sp) > +#ifndef __riscv_float_abi_soft > + FREG_S ft0, (12*SZREG + 0*SZFREG)(sp) > + FREG_S ft1, (12*SZREG + 1*SZFREG)(sp) > + FREG_S ft2, (12*SZREG + 2*SZFREG)(sp) > + FREG_S ft3, (12*SZREG + 3*SZFREG)(sp) > + FREG_S ft4, (12*SZREG + 4*SZFREG)(sp) > + FREG_S ft5, (12*SZREG + 5*SZFREG)(sp) > + FREG_S ft6, (12*SZREG + 6*SZFREG)(sp) > + FREG_S ft7, (12*SZREG + 7*SZFREG)(sp) > + FREG_S fa0, (12*SZREG + 8*SZFREG)(sp) > + FREG_S fa1, (12*SZREG + 9*SZFREG)(sp) > + FREG_S fa2, (12*SZREG + 10*SZFREG)(sp) > + FREG_S fa3, (12*SZREG + 11*SZFREG)(sp) > + FREG_S fa4, (12*SZREG + 12*SZFREG)(sp) > + FREG_S fa5, (12*SZREG + 13*SZFREG)(sp) > + FREG_S fa6, (12*SZREG + 14*SZFREG)(sp) > + FREG_S fa7, (12*SZREG + 15*SZFREG)(sp) > + FREG_S ft8, (12*SZREG + 16*SZFREG)(sp) > + FREG_S ft9, (12*SZREG + 17*SZFREG)(sp) > + FREG_S ft10, (12*SZREG + 18*SZFREG)(sp) > + FREG_S ft11, (12*SZREG + 19*SZFREG)(sp) > +#endif > + > + addi a0, a0, SZREG > + call __tls_get_addr > + addi a0, a0, -TLS_DTV_OFFSET > + > + REG_L ra, 0*SZREG(sp) > + REG_L a1, 1*SZREG(sp) > + REG_L a2, 2*SZREG(sp) > + REG_L a3, 3*SZREG(sp) > + REG_L a4, 4*SZREG(sp) > + REG_L a5, 5*SZREG(sp) > + REG_L a6, 6*SZREG(sp) > + REG_L a7, 7*SZREG(sp) > + REG_L t3, 8*SZREG(sp) > + REG_L t4, 9*SZREG(sp) > + REG_L t5, 10*SZREG(sp) > + REG_L t6, 11*SZREG(sp) > +#ifndef __riscv_float_abi_soft > + FREG_L ft0, (12*SZREG + 0*SZFREG)(sp) > + FREG_L ft1, (12*SZREG + 1*SZFREG)(sp) > + FREG_L ft2, (12*SZREG + 2*SZFREG)(sp) > + FREG_L ft3, (12*SZREG + 3*SZFREG)(sp) > + FREG_L ft4, (12*SZREG + 4*SZFREG)(sp) > + FREG_L ft5, (12*SZREG + 5*SZFREG)(sp) > + FREG_L ft6, (12*SZREG + 6*SZFREG)(sp) > + FREG_L ft7, (12*SZREG + 7*SZFREG)(sp) > + FREG_L fa0, (12*SZREG + 8*SZFREG)(sp) > + FREG_L fa1, (12*SZREG + 9*SZFREG)(sp) > + FREG_L fa2, (12*SZREG + 10*SZFREG)(sp) > + FREG_L fa3, (12*SZREG + 11*SZFREG)(sp) > + FREG_L fa4, (12*SZREG + 12*SZFREG)(sp) > + FREG_L fa5, (12*SZREG + 13*SZFREG)(sp) > + FREG_L fa6, (12*SZREG + 14*SZFREG)(sp) > + FREG_L fa7, (12*SZREG + 15*SZFREG)(sp) > + FREG_L ft8, (12*SZREG + 16*SZFREG)(sp) > + FREG_L ft9, (12*SZREG + 17*SZFREG)(sp) > + FREG_L ft10, (12*SZREG + 18*SZFREG)(sp) > + FREG_L ft11, (12*SZREG + 19*SZFREG)(sp) > +#endif > + addi sp, sp, FRAME_SIZE > + j .Lret > +END (_dl_tlsdesc_dynamic) > +#endif > diff --git a/sysdeps/riscv/dl-tlsdesc.h b/sysdeps/riscv/dl-tlsdesc.h > new file mode 100644 > index 0000000000..3156f34e9c > --- /dev/null > +++ b/sysdeps/riscv/dl-tlsdesc.h > @@ -0,0 +1,49 @@ > +/* Thread-local storage descriptor handling in the ELF dynamic linker. > + RISC-V version. > + Copyright (C) 2011-2023 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 > + . */ > + > +#ifndef _DL_TLSDESC_H > +# define _DL_TLSDESC_H 1 > + > +#include > + > +/* Type used to represent a TLS descriptor in the GOT. */ > +struct tlsdesc > +{ > + ptrdiff_t (*entry) (struct tlsdesc *); > + void *arg; > +}; > + > +/* Type used as the argument in a TLS descriptor for a symbol that > + needs dynamic TLS offsets. */ > +struct tlsdesc_dynamic_arg > +{ > + tls_index tlsinfo; > + size_t gen_count; > +}; > + > +extern unsigned long attribute_hidden > + _dl_tlsdesc_return(struct tlsdesc *), > + _dl_tlsdesc_undefweak(struct tlsdesc *); > + > +# ifdef SHARED > +extern void *_dl_make_tlsdesc_dynamic (struct link_map *, size_t); > +extern unsigned long attribute_hidden _dl_tlsdesc_dynamic(struct tlsdesc= *); > +# endif > + > +#endif /* _DL_TLSDESC_H */ > \ No newline at end of file > diff --git a/sysdeps/riscv/linkmap.h b/sysdeps/riscv/linkmap.h > index ac170bb342..2fa3f6d43f 100644 > --- a/sysdeps/riscv/linkmap.h > +++ b/sysdeps/riscv/linkmap.h > @@ -1,4 +1,5 @@ > struct link_map_machine > { > ElfW(Addr) plt; /* Address of .plt. */ > + void *tlsdesc_table; /* Address of TLS descriptor hash table. */ > }; > diff --git a/sysdeps/riscv/tlsdesc.c b/sysdeps/riscv/tlsdesc.c > new file mode 100644 > index 0000000000..a76aaa9fc5 > --- /dev/null > +++ b/sysdeps/riscv/tlsdesc.c > @@ -0,0 +1,38 @@ > +/* Manage TLS descriptors. RISC-V version. > + Copyright (C) 2005-2023 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 > + > +/* Unmap the dynamic object, but also release its TLS descriptor table > + if there is one. */ > + > +void > +_dl_unmap (struct link_map *map) > +{ > + _dl_unmap_segments (map); > + > +#ifdef SHARED > + if (map->l_mach.tlsdesc_table) > + htab_delete (map->l_mach.tlsdesc_table); > +#endif > +} > diff --git a/sysdeps/riscv/tlsdesc.sym b/sysdeps/riscv/tlsdesc.sym > new file mode 100644 > index 0000000000..652e72ea58 > --- /dev/null > +++ b/sysdeps/riscv/tlsdesc.sym > @@ -0,0 +1,19 @@ > +#include > +#include > +#include > +#include > +#include > +#include > + > +-- > + > +-- Abuse tls.h macros to derive offsets relative to the thread register. > + > +TLSDESC_ARG offsetof(struct tlsdesc, arg) > +TLSDESC_GEN_COUNT offsetof(struct tlsdesc_dynamic_arg, gen_count) > +TLSDESC_MODID offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_m= odule) > +TLSDESC_MODOFF offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_o= ffset) > +TCBHEAD_DTV offsetof(tcbhead_t, dtv) - sizeof(tcbhead_t) - TL= S_TCB_OFFSET > +DTV_COUNTER offsetof(dtv_t, counter) > +TLS_DTV_UNALLOCATED TLS_DTV_UNALLOCATED > +TLS_DTV_OFFSET TLS_DTV_OFFSET > -- > 2.41.0 >