From a8cd2e84e0ea3e5c2bd53f5924814f1539f83623 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 21 May 2024 11:20:44 +0900 Subject: [PATCH] Support R_PPC64_TPREL16_LO_DS Fixes https://github.com/rui314/mold/issues/1262 --- elf/arch-ppc64v1.cc | 4 ++++ elf/arch-ppc64v2.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/elf/arch-ppc64v1.cc b/elf/arch-ppc64v1.cc index 3a46b469ff..cef71954f0 100644 --- a/elf/arch-ppc64v1.cc +++ b/elf/arch-ppc64v1.cc @@ -271,6 +271,9 @@ void InputSection::apply_reloc_alloc(Context &ctx, u8 *base) { case R_PPC64_TPREL16_LO: *(ub16 *)loc = lo(S + A - ctx.tp_addr); break; + case R_PPC64_TPREL16_LO_DS: + *(ub16 *)loc |= (S + A - ctx.tp_addr) & 0xfffc; + break; case R_PPC64_GOT_TPREL16_LO_DS: *(ub16 *)loc |= (sym.get_gottp_addr(ctx) - TOC) & 0xfffc; break; @@ -381,6 +384,7 @@ void InputSection::scan_relocations(Context &ctx) { break; case R_PPC64_TPREL16_HA: case R_PPC64_TPREL16_LO: + case R_PPC64_TPREL16_LO_DS: check_tlsle(ctx, sym, rel); break; case R_PPC64_REL32: diff --git a/elf/arch-ppc64v2.cc b/elf/arch-ppc64v2.cc index 61e2d6e79f..15f855af3a 100644 --- a/elf/arch-ppc64v2.cc +++ b/elf/arch-ppc64v2.cc @@ -331,6 +331,9 @@ void InputSection::apply_reloc_alloc(Context &ctx, u8 *base) { case R_PPC64_TPREL16_LO: *(ul16 *)loc = lo(S + A - ctx.tp_addr); break; + case R_PPC64_TPREL16_LO_DS: + *(ul16 *)loc |= (S + A - ctx.tp_addr) & 0xfffc; + break; case R_PPC64_TPREL34: write34(loc, S + A - ctx.tp_addr); break; @@ -451,6 +454,7 @@ void InputSection::scan_relocations(Context &ctx) { break; case R_PPC64_TPREL16_HA: case R_PPC64_TPREL16_LO: + case R_PPC64_TPREL16_LO_DS: case R_PPC64_TPREL34: check_tlsle(ctx, sym, rel); break;