[v4,0/3] RISC-V: Implement TLS Descriptors.

Message ID 20230914084033.222120-1-ishitatsuyuki@gmail.com
Series RISC-V: Implement TLS Descriptors. |


Tatsuyuki Ishi Sept. 14, 2023, 8:40 a.m. UTC
  This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per
the ratified specification at [1].

The latest version of related binutils and gcc patches are at [2,3].

Passes binutils and gcc tests for rv64gc. For glibc I only tested elf/ as
other subsystems sometimes doesn't work well under qemu. These are the

- elf/tst-tls1-static
- elf/tst-tls1-static-non-pie

The TLSDESC relocations always needs to be handled by the dynamic linker,
but the process is skipped for static executables. I will look into
changing binutils to always relax TLSDESC to LE such that we can avoid
this issue.

This contribution is made on behalf of Blue Whale Systems, which has
copyright assignment on file with the FSF.

v2: Fix end-of-file newlines.
v3: Fix segfaulting on the slow path of TLSDESC resolver.
    Fix handling of lazy relocations.
v4: Fix compiler warnings.
    Fix fast path stack alignment pointed out by Andrew.
    Fix style issues pointed out by Adhemerval.
    Include 2 missing prerequisite commits.
    Update localplt list.

[1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373
[2]: https://inbox.sourceware.org/binutils/20230831171345.49052-1-ishitatsuyuki@gmail.com/
[3]: https://inbox.sourceware.org/gcc-patches/20230908104923.31154-1-ishitatsuyuki@gmail.com/

Tatsuyuki Ishi (3):
  RISC-V: Add include guard for dl-tls.h.
  RISC-V: Add TLSDESC reloc definitions.
  RISC-V: Implement TLS Descriptors.

 elf/elf.h                                   |   5 +
 sysdeps/riscv/Makefile                      |  13 ++
 sysdeps/riscv/dl-lookupcfg.h                |  27 +++
 sysdeps/riscv/dl-machine.h                  |  50 ++++-
 sysdeps/riscv/dl-tls.h                      |   4 +
 sysdeps/riscv/dl-tlsdesc.S                  | 205 ++++++++++++++++++++
 sysdeps/riscv/dl-tlsdesc.h                  |  48 +++++
 sysdeps/riscv/linkmap.h                     |   1 +
 sysdeps/riscv/tlsdesc.c                     |  38 ++++
 sysdeps/riscv/tlsdesc.sym                   |  19 ++
 sysdeps/unix/sysv/linux/riscv/localplt.data |   2 +
 11 files changed, 411 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