1# REQUIRES: ppc
2# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
3# RUN: echo '.globl b; b:' | llvm-mc -filetype=obj -triple=powerpc - -o %t1.o
4# RUN: ld.lld -shared %t1.o -soname=t1.so -o %t1.so
5
6# RUN: ld.lld %t.o %t1.so -o %t
7# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
8# RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
9# RUN: llvm-readobj -x .got %t | FileCheck --check-prefix=HEX %s
10# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
11
12## Check we can handle R_PPC_GOT16, which may be generated by -fpic code.
13
14# SEC: .got PROGBITS 00020068 020068 000014
15
16# RELOC:      .rela.dyn {
17# RELOC-NEXT:   0x1002021C R_PPC_GLOB_DAT b 0x0
18# RELOC-NEXT: }
19
20# NM: 10030220 d a
21
22## The GOT slot of a can be filled at link time.
23# HEX: section '.got':
24# HEX: 0x1002020c {{[0-9a-f]+}} 00000000 00000000 10030220
25
26## a: &.got[3] - _GLOBAL_OFFSET_TABLE_ = 12
27## b: &.got[4] - _GLOBAL_OFFSET_TABLE_ = 16
28# CHECK: lwz 3, 12(30)
29# CHECK: lwz 4, 16(30)
30
31lwz 3,a@got(30)
32lwz 4,b@got(30)
33
34.data
35a:
36.long _GLOBAL_OFFSET_TABLE_
37