diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -1371,8 +1371,8 @@ if (oneof(expr)) { in.gotPlt->hasGotPltOffRel = true; - } else if (oneof( - expr)) { + } else if (oneof(expr)) { in.got->hasGotOffRel = true; } diff --git a/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s b/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s --- a/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s +++ b/lld/test/ELF/ppc32-ifunc-nonpreemptible-pic.s @@ -7,12 +7,12 @@ # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s # RELOC: .rela.dyn { -# RELOC-NEXT: 0x30248 R_PPC_RELATIVE - 0x101A8 -# RELOC-NEXT: 0x3024C R_PPC_IRELATIVE - 0x10188 +# RELOC-NEXT: 0x30254 R_PPC_RELATIVE - 0x101A8 +# RELOC-NEXT: 0x30258 R_PPC_IRELATIVE - 0x10188 # RELOC-NEXT: } # SYM: 000101a8 0 FUNC GLOBAL DEFAULT {{.*}} func -# HEX: 0x00030248 00000000 +# HEX: 0x00030254 00000000 .section .got2,"aw" .long func diff --git a/lld/test/ELF/ppc32-reloc-pltrel.s b/lld/test/ELF/ppc32-reloc-pltrel.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/ppc32-reloc-pltrel.s @@ -0,0 +1,35 @@ +# REQUIRES: ppc + +## Ensure R_PPC_PLTREL retains .got even in the absence of +## .got/_GLOBAL_OFFSET_TABLE_ references. + +# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t.so +# RUN: llvm-readobj -Sdr %t.so | FileCheck %s + +.section .got2,"aw",@progbits +.set .LTOC, .+0x8000 + +.text +.L0: +addis 30,30,.LTOC-.L0@ha +addi 30,30,.LTOC-.L0@l +bl baz+0x8000@plt + +## DT_PPC_GOT must point to .got, which must have the 12-byte header. +## The only relocation is an R_PPC_JMP_SLOT. + +# CHECK: Sections [ +# CHECK: Name: .got ( +# CHECK: Address: +# CHECK-SAME: {{ }}[[#%x,GOT:]] +# CHECK: Size: +# CHECK-SAME: {{ 12$}} +# CHECK: DynamicSection [ +# CHECK-NEXT: Tag Type Name/Value +# CHECK: 0x70000000 PPC_GOT [[#GOT]] +# CHECK: Relocations [ +# CHECK-NEXT: Section ([[#]]) .rela.plt { +# CHECK-NEXT: 0x[[#%x,]] R_PPC_JMP_SLOT baz 0x0 +# CHECK-NEXT: } +# CHECK-NEXT: ] diff --git a/lld/test/ELF/ppc32-reloc-rel.s b/lld/test/ELF/ppc32-reloc-rel.s --- a/lld/test/ELF/ppc32-reloc-rel.s +++ b/lld/test/ELF/ppc32-reloc-rel.s @@ -11,13 +11,13 @@ beq 1f 1: # CHECK-LABEL: section .R_PPC_REL14: -# CHECK: 100100b4: bt 2, 0x100100b8 +# CHECK: 100100f4: bt 2, 0x100100f8 .section .R_PPC_REL24,"ax",@progbits b 1f 1: # CHECK-LABEL: section .R_PPC_REL24: -# CHECK: b 0x100100bc +# CHECK: b 0x100100fc .section .R_PPC_REL32,"ax",@progbits .long 1f - . @@ -29,10 +29,10 @@ b 1f@PLT+32768 1: # CHECK-LABEL: section .R_PPC_PLTREL24: -# CHECK: b 0x100100c4 +# CHECK: b 0x10010104 .section .R_PPC_LOCAL24PC,"ax",@progbits b 1f@local 1: # CHECK-LABEL: section .R_PPC_LOCAL24PC: -# CHECK: b 0x100100c8 +# CHECK: b 0x10010108