1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t.o 3# RUN: ld.lld -shared %t.o -o %t.so 4# RUN: llvm-readobj --sections -r %t.so | FileCheck %s 5# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s --check-prefix=DIS 6 7.type tls0,@object 8.section .tbss,"awT",@nobits 9.globl tls0 10.align 4 11tls0: 12 .long 0 13 .size tls0, 4 14 15.type tls1,@object 16.globl tls1 17.align 4 18tls1: 19 .long 0 20 .size tls1, 4 21 22.type tls2,@object 23.globl tls2 24.hidden tls2 25.align 4 26tls2: 27 .long 0 28 .size tls2, 8 29 30.section .text 31.globl _start 32_start: 33leal tls0@tlsgd(,%ebx,1),%eax 34call __tls_get_addr@plt 35 36leal tls1@tlsgd(,%ebx,1),%eax 37call __tls_get_addr@plt 38 39leal tls2@tlsldm(%ebx),%eax 40call __tls_get_addr@plt 41leal tls2@dtpoff(%eax),%edx 42 43leal tls2@tlsldm(%ebx),%eax 44call __tls_get_addr@plt 45leal tls2@dtpoff+4(%eax),%edx 46 47movl %gs:0,%eax 48addl tls0@gotntpoff(%ebx),%eax 49 50movl %gs:0,%eax 51addl tls1@gotntpoff(%ebx),%eax 52 53# CHECK: Name: .got ( 54# CHECK-NEXT: Type: SHT_PROGBITS 55# CHECK-NEXT: Flags [ 56# CHECK-NEXT: SHF_ALLOC 57# CHECK-NEXT: SHF_WRITE 58# CHECK-NEXT: ] 59# CHECK-NEXT: Address: 0x2358 60# CHECK-NEXT: Offset: 0x358 61# CHECK-NEXT: Size: 32 62# CHECK-NEXT: Link: 0 63# CHECK-NEXT: Info: 0 64# CHECK-NEXT: AddressAlignment: 4 65# CHECK-NEXT: EntrySize: 0 66 67# CHECK: Relocations [ 68# CHECK: Section ({{.+}}) .rel.dyn { 69# CHECK-NEXT: 0x2368 R_386_TLS_DTPMOD32 - 0x0 70# CHECK-NEXT: 0x2358 R_386_TLS_DTPMOD32 tls0 0x0 71# CHECK-NEXT: 0x235C R_386_TLS_DTPOFF32 tls0 0x0 72# CHECK-NEXT: 0x2370 R_386_TLS_TPOFF tls0 0x0 73# CHECK-NEXT: 0x2360 R_386_TLS_DTPMOD32 tls1 0x0 74# CHECK-NEXT: 0x2364 R_386_TLS_DTPOFF32 tls1 0x0 75# CHECK-NEXT: 0x2374 R_386_TLS_TPOFF tls1 0x0 76# CHECK-NEXT: } 77 78# DIS: Disassembly of section .text: 79# DIS-EMPTY: 80# DIS-NEXT: <_start>: 81## General dynamic model: 82## -4128 and -4120 are first and second GOT entries offsets. 83## Each one is a pair of records. 84# DIS-NEXT: 1260: leal -4128(,%ebx), %eax 85# DIS-NEXT: 1267: calll 0x12d0 86# DIS-NEXT: 126c: leal -4120(,%ebx), %eax 87# DIS-NEXT: 1273: calll 0x12d0 88## Local dynamic model: 89## -16 is a local module tls index offset. 90# DIS-NEXT: 1278: leal -4112(%ebx), %eax 91# DIS-NEXT: 127e: calll 0x12d0 92# DIS-NEXT: 1283: leal 8(%eax), %edx 93# DIS-NEXT: 1289: leal -4112(%ebx), %eax 94# DIS-NEXT: 128f: calll 0x12d0 95# DIS-NEXT: 1294: leal 12(%eax), %edx 96## Initial exec model: 97# DIS-NEXT: 129a: movl %gs:0, %eax 98# DIS-NEXT: 12a0: addl -4104(%ebx), %eax 99# DIS-NEXT: 12a6: movl %gs:0, %eax 100# DIS-NEXT: 12ac: addl -4100(%ebx), %eax 101