Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -47,6 +47,7 @@ TargetInfo *Target; static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); } +static void or32be(uint8_t *P, int32_t V) { write32be(P, read32be(P) | V); } StringRef getRelName(uint32_t Type) { return getELFRelocationTypeName(Config->EMachine, Type); @@ -965,13 +966,25 @@ case R_PPC_ADDR16_LO: write16be(Loc, applyPPCLo(Val)); break; + case R_PPC_REL24: + or32be(Loc, Val & 0x3FFFFFC); + break; + case R_PPC_REL32: + write32be(Loc, Val); + break; default: fatal("unrecognized reloc " + Twine(Type)); } } RelExpr PPCTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { - return R_ABS; + switch (Type) { + case R_PPC_REL24: + case R_PPC_REL32: + return R_PC; + default: + return R_ABS; + } } PPC64TargetInfo::PPC64TargetInfo() { Index: test/ELF/ppc-relocs.s =================================================================== --- test/ELF/ppc-relocs.s +++ test/ELF/ppc-relocs.s @@ -28,3 +28,15 @@ # CHECK: 11008: 38 84 10 04 addi 4, 4, 4100 # CHECK: mystr: # CHECK: 1100c: 62 6c 61 68 ori 12, 19, 24936 + +.align 2 +.section .R_PPC_REL24,"ax",@progbits +.globl .FR_PPC_REL24 +.FR_PPC_REL24: + b .Lfoox +.section .R_PPC_REL24_2,"ax",@progbits +.Lfoox: + +# CHECK: Disassembly of section .R_PPC_REL24: +# CHECK: .FR_PPC_REL24: +# CHECK: 11014: 48 00 00 04 b .+4