107 lines · plain
1# REQUIRES: ppc2# RUN: split-file %s %t3# RUN: llvm-mc --triple=ppc64le %t/a.s --filetype=obj -o %t/a.o4# RUN: llvm-mc --triple=ppc64le %t/b.s --filetype=obj -o %t/b.o5# RUN: llvm-mc --triple=ppc64le %t/tga.s --filetype=obj -o %t/tga.o6 7## User code can call __tls_get_addr by specifying the tls_index parameter.8## We need to allow R_PPC64_REL24/R_PPC64_REL24_NOTOC referencing __tls_get_addr9## without a pairing R_PPC64_TLSGD/R_PPC64_TLSLD.10# RUN: ld.lld --shared --fatal-warnings %t/b.o -o /dev/null11 12## Warn missing R_PPC64_TLSGD/R_PPC64_TLSLD.13# RUN: ld.lld --shared %t/a.o -o %t.so 2>&1 | FileCheck %s --check-prefix=WARN14# RUN: llvm-objdump -d --no-leading-addr %t.so | FileCheck %s --check-prefix=DIS15 16# RUN: ld.lld %t/a.o %t/tga.o -o %t2 2>&1 | FileCheck %s --check-prefix=WARN17# RUN: llvm-readelf -x .got %t2 | FileCheck %s --check-prefix=HEX18# RUN: llvm-objdump -d --no-leading-addr %t2 | FileCheck %s --check-prefix=DIS19 20# WARN: warning: {{.*}}.o: disable TLS relaxation due to R_PPC64_GOT_TLS* relocations without R_PPC64_TLSGD/R_PPC64_TLSLD relocations21 22## .got+0: x is local - relaxed to LE - its DTPMOD/DTPREL slots are link-time constants.23## DTPMOD is 1. DTPREL is st_value-0x8000 = -0x8000.24## .got+16: DTPMOD/DTPREL for _TLS_MODULE_BASE_ is 1 and 0, respectively.25## .got+32: TPOFFSET for x = st_value-0x700026# HEX: section '.got':27# HEX-NEXT: [[#%x,IGNORE:]] 50820210 00000000 01000000 0000000028# HEX-NEXT: [[#%x,IGNORE:]] 00000000 00000000 01000000 0000000029# HEX-NEXT: [[#%x,IGNORE:]] 0080ffff ffffffff 0090ffff ffffffff30 31## .TOC.-32768 = (.got+0x8000)-32768 = .got32# DIS-LABEL: <GeneralDynamic>:33# DIS-NEXT: addis 3, 2, 034# DIS-NEXT: addi 3, 3, -3274435# DIS-NEXT: bl [[#%x,TGA:]]36# DIS-LABEL: <GeneralDynamic_NOTOC>:37# DIS-NEXT: addis 3, 2, 038# DIS-NEXT: addi 3, 3, -3274439# DIS-NEXT: bl [[#TGA]]40 41## LocalDynamic references _TLS_MODULE_BASE_.42## .TOC.-32752 = (.got+0x8000)-32752 = .got+1643# DIS-LABEL: <LocalDynamic>:44# DIS-NEXT: addis 3, 2, 045# DIS-NEXT: addi 3, 3, -3276046# DIS-NEXT: bl [[#TGA]]47# DIS-LABEL: <LocalDynamic_NOTOC>:48# DIS-NEXT: addis 3, 2, 049# DIS-NEXT: addi 3, 3, -3276050# DIS-NEXT: bl [[#TGA]]51 52## Technically we don't have to disable IE to LE relaxation,53## but disabling it for implementation simplicity does not hurt.54# DIS-LABEL: <InitialExec>:55# DIS-NEXT: addis 3, 2, 056# DIS-NEXT: ld 3, -32728(3)57# DIS-NEXT: add 3, 3, 1358 59#--- a.s60GeneralDynamic:61 addis 3, 2, x@got@tlsgd@ha62 addi 3, 3, x@got@tlsgd@l63 bl __tls_get_addr64 nop65 66GeneralDynamic_NOTOC:67 addis 3, 2, x@got@tlsgd@ha68 addi 3, 3, x@got@tlsgd@l69 bl __tls_get_addr@notoc70 nop71 72LocalDynamic:73 addis 3, 2, x@got@tlsld@ha74 addi 3, 3, x@got@tlsld@l75 bl __tls_get_addr76 nop77 78LocalDynamic_NOTOC:79 addis 3, 2, x@got@tlsld@ha80 addi 3, 3, x@got@tlsld@l81 bl __tls_get_addr@notoc82 nop83 84InitialExec:85 addis 3, 2, x@got@tprel@ha86 ld 3, x@got@tprel@l(3)87 add 3, 3, x@tls88 89.globl _start90_start:91 92.section .tbss,"awT",@nobits93.globl x94x:95 .quad 096 97#--- b.s98CallOnly:99 bl __tls_get_addr100 nop101 blr102 103#--- tga.s104.globl __tls_get_addr105__tls_get_addr:106 blr107