From 3809f4ebabde98bfdc1fdcdad2963a874151820b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 17 Jan 2021 00:02:13 -0800 Subject: [PATCH] [ELF] Support R_PPC_ADDR24 (ba foo; bla foo) --- lld/ELF/Arch/PPC.cpp | 2 ++ lld/test/ELF/ppc32-reloc-addr.s | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp index 5b22e6cd3f5f..aaecef6ee94f 100644 --- a/lld/ELF/Arch/PPC.cpp +++ b/lld/ELF/Arch/PPC.cpp @@ -222,6 +222,7 @@ RelExpr PPC::getRelExpr(RelType type, const Symbol &s, case R_PPC_ADDR16_HA: case R_PPC_ADDR16_HI: case R_PPC_ADDR16_LO: + case R_PPC_ADDR24: case R_PPC_ADDR32: return R_ABS; case R_PPC_DTPREL16: @@ -345,6 +346,7 @@ void PPC::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { write32(loc, (read32(loc) & ~mask) | (val & mask)); break; } + case R_PPC_ADDR24: case R_PPC_REL24: case R_PPC_LOCAL24PC: case R_PPC_PLTREL24: { diff --git a/lld/test/ELF/ppc32-reloc-addr.s b/lld/test/ELF/ppc32-reloc-addr.s index 98bd61b1192b..78865b82ccbf 100644 --- a/lld/test/ELF/ppc32-reloc-addr.s +++ b/lld/test/ELF/ppc32-reloc-addr.s @@ -19,8 +19,13 @@ # CHECK-LABEL: section .R_PPC_ADDR16_LO: # CHECK: addi 4, 4, 4660 +.section .R_PPC_ADDR24,"ax",@progbits + ba a +# CHECK-LABEL: section .R_PPC_ADDR24: +# CHECK: ba 4660 + .section .R_PPC_ADDR32,"a",@progbits .long a .long b # HEX-LABEL: section .R_PPC_ADDR32: -# HEX-NEXT: 100000b4 00001234 000bcdef +# HEX-NEXT: {{.*}} 00001234 000bcdef