[RISCV][lld] Set the type of TLSDESC relocation's referenced local symbol to STT_NOTYPE
authorPaul Kirth <paulkirth@google.com>
Fri, 22 Mar 2024 19:27:41 +0000 (12:27 -0700)
committerTom Stellard <tstellar@redhat.com>
Tue, 14 May 2024 01:08:07 +0000 (18:08 -0700)
commit6cfa40e450cfe7980a0c4aa0e17a8367b89f8d39
tree457bf2561233f6e82c3d54004ee219907120afb0
parent1184a9cb30e6a12c883b918867f2f06bc3096fc0
[RISCV][lld] Set the type of TLSDESC relocation's referenced local symbol to STT_NOTYPE

When adding fixups for RISCV_TLSDESC_ADD_LO and RISCV_TLSDESC_LOAD_LO,
the local label added for RISCV TLSDESC relocations have STT_TLS set,
which is incorrect. Instead, these labels should have `STT_NOTYPE`.

This patch stops adding such fixups and avoid setting the STT_TLS on
these symbols. Failing to do so can cause LLD to emit an error `has an
STT_TLS symbol but doesn't have an SHF_TLS section`. We additionally,
adjust how LLD services these relocations to avoid errors with
incompatible relocation and symbol types.

Reviewers: topperc, MaskRay

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/85817

(cherry picked from commit dfe4ca9b7f4a422500d78280dc5eefd1979939e6)
lld/ELF/Relocations.cpp
lld/test/ELF/riscv-tlsdesc-relax.s
lld/test/ELF/riscv-tlsdesc.s
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp