1# REQUIRES: ppc 2# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o 3# RUN: echo '.tbss; .globl b, c; b: .zero 4; c:' | llvm-mc -filetype=obj -triple=powerpc - -o %t1.o 4# RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so 5# RUN: echo '.globl __tls_get_addr; __tls_get_addr:' | llvm-mc -filetype=obj -triple=powerpc - -o %tga.o 6 7# RUN: ld.lld -shared %t.o %t1.o -o %t.so 8# RUN: llvm-readobj -d %t.so | FileCheck --check-prefix=GD-DYN %s 9# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=GD-REL %s 10# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s 11 12# RUN: ld.lld %t.o %t1.o %tga.o -o %t 13# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s 14# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s 15 16# RUN: ld.lld %t.o %t1.so -o %t 17# RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s 18# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s 19 20## DT_PPC_GOT represents the address of _GLOBAL_OFFSET_TABLE_. 21# GD-DYN: PPC_GOT 0x20358 22 23# GD-REL: .rela.dyn { 24# GD-REL-NEXT: 0x20358 R_PPC_DTPMOD32 a 0x0 25# GD-REL-NEXT: 0x2035C R_PPC_DTPREL32 a 0x0 26# GD-REL-NEXT: 0x20360 R_PPC_DTPMOD32 b 0x0 27# GD-REL-NEXT: 0x20364 R_PPC_DTPREL32 b 0x0 28# GD-REL-NEXT: 0x20368 R_PPC_DTPMOD32 c 0x0 29# GD-REL-NEXT: 0x2036C R_PPC_DTPREL32 c 0x0 30# GD-REL-NEXT: } 31 32## &DTPMOD(a) - _GLOBAL_OFFSET_TABLE_ = 0x20078 - 0x20078 = 0 33# GD: addi 3, 31, 0 34# GD-NEXT: bl 0x1028c 35# GD-NEXT: lwz 3, 0(3) 36 37## &DTPMOD(b) - _GLOBAL_OFFSET_TABLE_ = 0x20080 - 0x20078 = 8 38# GD-NEXT: addi 3, 31, 8 39# GD-NEXT: bl 0x1028c 40# GD-NEXT: lwz 3, 0(3) 41 42## &DTPMOD(c) - _GLOBAL_OFFSET_TABLE_ = 0x20088 - 0x20078 = 16 43# GD-NEXT: addi 3, 9, 16 44# GD-NEXT: bl 0x1028c 45# GD-NEXT: lwz 3, 0(3) 46 47# NOREL: no relocations 48 49## a@tprel = 8-0x7000 = -28664 50# LE: addis 3, 2, 0 51# LE-NEXT: addi 3, 3, -28664 52# LE-NEXT: lwz 3, 0(3) 53## b@tprel = 12-0x7000 = -28660 54# LE-NEXT: addis 3, 2, 0 55# LE-NEXT: addi 3, 3, -28660 56# LE-NEXT: lwz 3, 0(3) 57## c@tprel = 16-0x7000 = -28656 58# LE-NEXT: addis 3, 2, 0 59# LE-NEXT: addi 3, 3, -28656 60# LE-NEXT: lwz 3, 0(3) 61 62# IE-REL: .rela.dyn { 63# IE-REL-NEXT: 0x10020274 R_PPC_TPREL32 b 0x0 64# IE-REL-NEXT: 0x10020278 R_PPC_TPREL32 c 0x0 65# IE-REL-NEXT: } 66 67## a is relaxed to use LE. 68## a@tprel = st_value(a)-0x8000 = -28664 69# IE: addis 3, 2, 0 70# IE-NEXT: addi 3, 3, -28664 71# IE-NEXT: lwz 3, 0(3) 72## &.got[0] - _GLOBAL_OFFSET_TABLE_ = 0 73# IE-NEXT: lwz 3, 0(31) 74# IE-NEXT: add 3, 3, 2 75# IE-NEXT: lwz 3, 0(3) 76## &.got[1] - _GLOBAL_OFFSET_TABLE_ = 4 77# IE-NEXT: lwz 3, 4(9) 78# IE-NEXT: add 3, 3, 2 79# IE-NEXT: lwz 3, 0(3) 80 81addi 3, 31, a@got@tlsgd 82bl __tls_get_addr(a@tlsgd) 83lwz 3, 0(3) 84 85addi 3, 31, b@got@tlsgd 86bl __tls_get_addr(b@tlsgd) 87lwz 3, 0(3) 88 89## -fpic may use a different register (e.g. r9). 90addi 3, 9, c@got@tlsgd 91bl __tls_get_addr(c@tlsgd) 92lwz 3, 0(3) 93 94.section .tbss 95.globl a 96.zero 8 97a: 98.zero 4 99