[lld] 3809f4e - [ELF] Support R_PPC_ADDR24 (ba foo; bla foo)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 17 00:02:20 PST 2021


Author: Fangrui Song
Date: 2021-01-17T00:02:13-08:00
New Revision: 3809f4ebabde98bfdc1fdcdad2963a874151820b

URL: https://github.com/llvm/llvm-project/commit/3809f4ebabde98bfdc1fdcdad2963a874151820b
DIFF: https://github.com/llvm/llvm-project/commit/3809f4ebabde98bfdc1fdcdad2963a874151820b.diff

LOG: [ELF] Support R_PPC_ADDR24 (ba foo; bla foo)

Added: 
    

Modified: 
    lld/ELF/Arch/PPC.cpp
    lld/test/ELF/ppc32-reloc-addr.s

Removed: 
    


################################################################################
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", at progbits
+  ba a
+# CHECK-LABEL: section .R_PPC_ADDR24:
+# CHECK: ba 4660
+
 .section .R_PPC_ADDR32,"a", at progbits
   .long a
   .long b
 # HEX-LABEL: section .R_PPC_ADDR32:
-# HEX-NEXT: 100000b4 00001234 000bcdef
+# HEX-NEXT: {{.*}} 00001234 000bcdef


        


More information about the llvm-commits mailing list