[PATCH] riscv: Implement TLS Descriptors
Andreas K. Huettel
dilfridge@gentoo.org
Wed Jul 15 11:28:04 GMT 2026
Hi Luke,
> Oh, sorry for not noticing it happens to be the code freeze period, it's my first time
> contributing to glibc :)
No problem at all, no worries.
> That's not in an urgent feature so I can wait till the next
> development window. May I ask is that just leave the patch as it is, and ping later?
Keep developing the patch as usual, posting to the list and getting
reviews. Just the final push should wait until after the release.
Cheers,
Andreas
> I'll keep track on the releasing process and go back to it after it's done.
> Thank you very much!
> Best,
> Luke Zhuang
> ------------------------------------------------------------------
> From:Andreas K. Huettel <dilfridge@gentoo.org>
> Send Time:Wed, Jul 15, 2026, 09:57
> To:"libc-alpha"<libc-alpha@sourceware.org>
> CC:"adhemerval.zanella"<adhemerval.zanella@linaro.org>; fweimer<fweimer@redhat.com>; schwab<schwab@suse.de>; palmer<palmer@rivosinc.com>; andrew<andrew@sifive.com>; rui314<rui314@gmail.com>; ruiu<ruiu@bluewhale.systems>; Luke Zhuang<luke.zhuang@linux.alibaba.com>; Tatsuyuki Ishi<ishitatsuyuki@gmail.com>
> Subject:Re: [PATCH] riscv: Implement TLS Descriptors
> Am Dienstag, 14. Juli 2026, 23:30:42 Japanische Normalzeit schrieb Luke Zhuang:
> > From: "Luke Zhuang" <luke.zhuang@linux.alibaba.com>
> >
> > Implement TLS Descriptors (TLSDESC) for RISC-V, as specified by the
> > RISC-V psABI TLSDESC extension [1].
> >
> That's post-release material.
> > This adds the RISC-V TLSDESC relocation handling and the three resolver
> > entry points used by the dynamic loader:
> >
> > _dl_tlsdesc_undefweak
> > _dl_tlsdesc_return
> > _dl_tlsdesc_dynamic
> >
> > The dynamic resolver implements the usual fast path by checking the DTV
> > generation counter, and falls back to __tls_get_addr on the slow path.
> >
> > This work is based on Tatsuyuki Ishi's original patch series [2], and
> > is being relanded with his authorization. The reland includes the
> > following updates:
> >
> > * Do not save and restore vector registers in _dl_tlsdesc_dynamic.
> > The RISC-V psABI now defines vector registers and vector CSRs as
> > caller-clobbered across TLSDESC calls [3], so preserving live vector
> > state is the compiler's responsibility.
> >
> > * Call HIDDEN_JUMPTARGET(__tls_get_addr) from ld.so, avoiding a PLT
> > reference to __tls_get_addr.
> >
> > * Publish TLSDESC entries in elf_machine_rela in arg-before-entry
> > order, and use a volatile tlsdesc pointer, matching the ordering
> > used by other architectures.
> >
> > * Add sysdeps/riscv/tst-gnu2-tls2.h to test that the RISC-V TLSDESC
> > resolver preserves the required caller-saved GPR and FPR state
> > across the slow path.
> >
> > Basic GCC and binutils support for RISC-V TLSDESC relocations is already
> > upstream [4][5]. Linker relaxation support is on the way but should not
> > be a blocker.
> >
> > [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373 >
> > [2] https://inbox.sourceware.org/libc-alpha/09A14C77-9EEA-4707-9E36-D3AAF8A98B24@gmail.com/T/#u <https://inbox.sourceware.org/libc-alpha/09A14C77-9EEA-4707-9E36-D3AAF8A98B24@gmail.com/T/#u >
> > [3] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/496 <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/496 >
> > [4] https://gcc.gnu.org/cgit/gcc/commit/?id=97069657c4e40b209c7b774e12faaca13812a86c <https://gcc.gnu.org/cgit/gcc/commit/?id=97069657c4e40b209c7b774e12faaca13812a86c >
> > [5] https://sourceware.org/git/?p=binutils-gdb.git <https://sourceware.org/git/?p=binutils-gdb.git >;a=commitdiff;h=159afbb7617d2c8a9cd3f3350374711f37f60442
> >
> > Co-authored-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
> > Signed-off-by: Luke Zhuang <luke.zhuang@linux.alibaba.com>
> > ---
> > sysdeps/riscv/Makefile | 10 ++
> > sysdeps/riscv/dl-lookupcfg.h | 27 +++++
> > sysdeps/riscv/dl-machine.h | 54 ++++++++-
> > sysdeps/riscv/dl-tlsdesc.S | 221 ++++++++++++++++++++++++++++++++++
> > sysdeps/riscv/dl-tlsdesc.h | 48 ++++++++
> > sysdeps/riscv/linkmap.h | 1 +
> > sysdeps/riscv/preconfigure | 1 +
> > sysdeps/riscv/tlsdesc.c | 38 ++++++
> > sysdeps/riscv/tlsdesc.sym | 19 +++
> > sysdeps/riscv/tst-gnu2-tls2.h | 201 +++++++++++++++++++++++++++++++
> > 10 files changed, 619 insertions(+), 1 deletion(-)
> > 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
> > create mode 100644 sysdeps/riscv/tst-gnu2-tls2.h
> >
--
PD Dr. Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer
(council, comrel, toolchain, base-system, perl, libreoffice)
https://wiki.gentoo.org/wiki/User:Dilfridge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 870 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260715/1b2d03ca/attachment.sig>
More information about the Libc-alpha
mailing list