Skip to content

Commit

Permalink
Fix R_PPC64_DTPREL16_LO_DS
Browse files Browse the repository at this point in the history
Fixes #1192
  • Loading branch information
rui314 committed Feb 23, 2024
1 parent 5b5f431 commit 6d8e6af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elf/arch-ppc64v1.cc
Expand Up @@ -263,7 +263,7 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
*(ub16 *)loc = lo(S + A - ctx.dtp_addr);
break;
case R_PPC64_DTPREL16_LO_DS:
*(ub16 *)loc |= ((S + A - ctx.dtp_addr) & 0x3fff) << 2;
*(ub16 *)loc |= (S + A - ctx.dtp_addr) & 0xfffc;
break;
case R_PPC64_TPREL16_HA:
*(ub16 *)loc = ha(S + A - ctx.tp_addr);
Expand Down
4 changes: 4 additions & 0 deletions elf/arch-ppc64v2.cc
Expand Up @@ -319,6 +319,9 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
case R_PPC64_DTPREL16_LO:
*(ul16 *)loc = lo(S + A - ctx.dtp_addr);
break;
case R_PPC64_DTPREL16_LO_DS:
*(ul16 *)loc |= (S + A - ctx.dtp_addr) & 0xfffc;
break;
case R_PPC64_DTPREL34:
write34(loc, S + A - ctx.dtp_addr);
break;
Expand Down Expand Up @@ -475,6 +478,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_PPC64_TLSLD:
case R_PPC64_DTPREL16_HA:
case R_PPC64_DTPREL16_LO:
case R_PPC64_DTPREL16_LO_DS:
case R_PPC64_DTPREL34:
break;
default:
Expand Down

0 comments on commit 6d8e6af

Please sign in to comment.