Index: ELF/Arch/PPC.cpp =================================================================== --- ELF/Arch/PPC.cpp +++ ELF/Arch/PPC.cpp @@ -33,6 +33,12 @@ switch (Type) { case R_PPC_REL24: case R_PPC_REL32: + // This allows lld to resolve local symbols when performing static linkage + // after LLVM started to use PLT relocations by default (see D38554). + // This is what bfd and gold are doing too. + // Non-local symbols will need a full PLT implementation, and once it lands + // local symbols should still avoid PLT table with static relocation model. + case R_PPC_PLTREL24: return R_PC; default: return R_ABS; @@ -54,6 +60,7 @@ case R_PPC_REL32: write32be(Loc, Val); break; + case R_PPC_PLTREL24: case R_PPC_REL24: write32be(Loc, read32be(Loc) | (Val & 0x3FFFFFC)); break; Index: test/ELF/ppc-relocs.s =================================================================== --- test/ELF/ppc-relocs.s +++ test/ELF/ppc-relocs.s @@ -76,3 +76,15 @@ # CHECK: Disassembly of section .R_PPC_ADDR32: # CHECK: .FR_PPC_ADDR32: # CHECK: 11024: 00 01 10 28 + +.align 2 +.section .R_PPC_PLTREL24,"ax",@progbits +.globl .R_PPC_PLTREL24 +.FR_PPC_PLTREL24: + b .Lfoox4@PLT +.section .R_PPC_PLTREL24_2,"ax",@progbits +.Lfoox4: + +# CHECK: Disassembly of section .R_PPC_PLTREL24: +# CHECK: .R_PPC_PLTREL24: +# CHECK: 11028: 48 00 00 04 b .+4