tools/mpy_ld.py: Fix handling of R_RISCV_TLSDESC_LOAD_LO12.

This commit fixes handling of the R_RISCV_TLSDESC_LOAD_LO12 RISC-V
object file relocation, fixing a couple of mistakes in its usage.

The condition check for TLS relocations presence and their rejection
when found in object files skipped checking for
R_RISCV_TLSDESC_LOAD_LO12 relocations, which is part of the set of
unsupported TLS relocations and thus needing an object file rejection.

Interestingly, that relocation name constant was actually misspelled
in the file - since it was skipped in the list of relocations being
checked its wrong name did pass unnoticed until now.  This is not a
critical change as the linker will raise an error about an unknown
relocation type rather than report a more descriptive message to the
user, but it's nice to have nonetheless.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti
2025-12-30 17:31:29 +01:00
parent 984027b88e
commit 1f67289a9e

View File

@@ -121,7 +121,7 @@ R_XTENSA_PDIFF32 = 59
R_RISCV_SET_ULEB128 = 60
R_RISCV_SUB_ULEB128 = 61
R_RISCV_TLSDESC_HI20 = 62
R_RISCC_TLSDESC_LOAD_LO12 = 63
R_RISCV_TLSDESC_LOAD_LO12 = 63
R_RISCV_TLSDESC_ADD_LO12 = 64
R_RISCV_TLSDESC_CALL = 65
@@ -682,6 +682,7 @@ def do_relocation_text(env, text_addr, r):
elif env.arch.name == "EM_RISCV" and r_info_type in (
R_RISCV_TLS_GD_HI20,
R_RISCV_TLSDESC_HI20,
R_RISCV_TLSDESC_LOAD_LO12,
R_RISCV_TLSDESC_ADD_LO12,
R_RISCV_TLSDESC_CALL,
):