1# REQUIRES: ppc
2## Test addend adjustment of R_PPC_PLTREL24 when copying relocations.
3## If r_addend indicates .got2, adjust it by the local .got2's output section offset.
4
5# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
6# RUN: ld.lld -r %t.o %t.o -o %t
7# RUN: llvm-readobj -r %t | FileCheck %s
8
9# RUN: ld.lld -shared --emit-relocs %t.o %t.o -o %t.so
10# RUN: llvm-readobj -r %t.so | FileCheck %s
11
12# CHECK:      .rela.adjust {
13# CHECK-NEXT:   R_PPC_REL16_HA .got2 0x8002
14# CHECK-NEXT:   R_PPC_REL16_LO .got2 0x8006
15# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x8000
16# CHECK-NEXT:   R_PPC_PLTREL24 bar 0x8000
17# CHECK-NEXT:   R_PPC_REL16_HA .got2 0x8006
18# CHECK-NEXT:   R_PPC_REL16_LO .got2 0x800A
19# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x8004
20# CHECK-NEXT:   R_PPC_PLTREL24 bar 0x8004
21# CHECK-NEXT: }
22# CHECK-NEXT: .rela.no_adjust {
23# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x0
24# CHECK-NEXT:   R_PPC_PLTREL24 foo 0x0
25# CHECK-NEXT: }
26.section .got2,"aw"
27.long 0
28
29.section .adjust,"ax"
30bcl 20,30,.L0
31.L0:
32addis 30,30,.got2+0x8000-.L0@ha
33addi 30,30,.got2+0x8000-.L0@l
34
35## Refers to .got2+addend, adjust.
36bl foo+0x8000@plt
37bl bar+0x8000@plt
38
39.section .no_adjust,"ax"
40## Refers to .got, no adjustment.
41bl foo@plt
42