1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 3// RUN: ld.lld %t -o %tout 4// RUN: llvm-readobj -S -l --symbols %tout | FileCheck %s 5// RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS 6 7.global _start 8_start: 9 movl %fs:a@tpoff, %eax 10 movl %fs:b@tpoff, %eax 11 movl %fs:c@tpoff, %eax 12 movl %fs:d@tpoff, %eax 13 14 .global a 15 .section .tbss,"awT",@nobits 16a: 17 .long 0 18 19 .global b 20 .section .tdata,"awT",@progbits 21b: 22 .long 1 23 24 .global c 25 .section .thread_bss,"awT",@nobits 26c: 27 .long 0 28 29 .global d 30 .section .thread_data,"awT",@progbits 31d: 32 .long 2 33 34// CHECK: Name: .tdata 35// CHECK-NEXT: Type: SHT_PROGBITS 36// CHECK-NEXT: Flags [ 37// CHECK-NEXT: SHF_ALLOC 38// CHECK-NEXT: SHF_TLS 39// CHECK-NEXT: SHF_WRITE 40// CHECK-NEXT: ] 41// CHECK-NEXT: Address: [[TDATA_ADDR:0x.*]] 42// CHECK-NEXT: Offset: 43// CHECK-NEXT: Size: 4 44// CHECK-NEXT: Link: 45// CHECK-NEXT: Info: 46// CHECK-NEXT: AddressAlignment: 47// CHECK-NEXT: EntrySize: 48// CHECK-NEXT: } 49// CHECK-NEXT: Section { 50// CHECK-NEXT: Index: 51// CHECK-NEXT: Name: .thread_data 52// CHECK-NEXT: Type: SHT_PROGBITS 53// CHECK-NEXT: Flags [ 54// CHECK-NEXT: SHF_ALLOC 55// CHECK-NEXT: SHF_TLS 56// CHECK-NEXT: SHF_WRITE 57// CHECK-NEXT: ] 58// CHECK-NEXT: Address: 59// CHECK-NEXT: Offset: 60// CHECK-NEXT: Size: 4 61// CHECK-NEXT: Link: 62// CHECK-NEXT: Info: 63// CHECK-NEXT: AddressAlignment: 64// CHECK-NEXT: EntrySize: 65// CHECK-NEXT: } 66// CHECK-NEXT: Section { 67// CHECK-NEXT: Index: 68// CHECK-NEXT: Name: .tbss 69// CHECK-NEXT: Type: SHT_NOBITS 70// CHECK-NEXT: Flags [ 71// CHECK-NEXT: SHF_ALLOC 72// CHECK-NEXT: SHF_TLS 73// CHECK-NEXT: SHF_WRITE 74// CHECK-NEXT: ] 75// CHECK-NEXT: Address: [[TBSS_ADDR:0x.*]] 76// CHECK-NEXT: Offset: 77// CHECK-NEXT: Size: 4 78// CHECK-NEXT: Link: 79// CHECK-NEXT: Info: 80// CHECK-NEXT: AddressAlignment: 81// CHECK-NEXT: EntrySize: 82// CHECK-NEXT: } 83// CHECK-NEXT: Section { 84// CHECK-NEXT: Index: 85// CHECK-NEXT: Name: .thread_bss 86// CHECK-NEXT: Type: SHT_NOBITS 87// CHECK-NEXT: Flags [ 88// CHECK-NEXT: SHF_ALLOC 89// CHECK-NEXT: SHF_TLS 90// CHECK-NEXT: SHF_WRITE 91// CHECK-NEXT: ] 92 93// 0x2021F4 = TBSS_ADDR + 4 94 95// CHECK-NEXT: Address: 0x2021F4 96// CHECK-NEXT: Offset: 97// CHECK-NEXT: Size: 4 98// CHECK-NEXT: Link: 99// CHECK-NEXT: Info: 100// CHECK-NEXT: AddressAlignment: 101// CHECK-NEXT: EntrySize: 102// CHECK-NEXT: } 103 104// Check that the TLS NOBITS sections weren't added to the R/W PT_LOAD's size. 105 106// CHECK: ProgramHeaders [ 107// CHECK: Type: PT_LOAD 108// CHECK: Type: PT_LOAD 109// CHECK: Type: PT_LOAD 110// CHECK: FileSize: 8 111// CHECK-NEXT: MemSize: 8 112// CHECK-NEXT: Flags [ 113// CHECK-NEXT: PF_R 114// CHECK-NEXT: PF_W 115// CHECK-NEXT: ] 116// CHECK: Type: PT_TLS 117// CHECK-NEXT: Offset: 118// CHECK-NEXT: VirtualAddress: [[TDATA_ADDR]] 119// CHECK-NEXT: PhysicalAddress: [[TDATA_ADDR]] 120// CHECK-NEXT: FileSize: 8 121// CHECK-NEXT: MemSize: 16 122// CHECK-NEXT: Flags [ 123// CHECK-NEXT: PF_R 124// CHECK-NEXT: ] 125// CHECK-NEXT: Alignment: 126// CHECK-NEXT: } 127 128// CHECK: Symbols [ 129// CHECK: Name: a 130// CHECK-NEXT: Value: 0x8 131// CHECK-NEXT: Size: 132// CHECK-NEXT: Binding: Global 133// CHECK-NEXT: Type: TLS 134// CHECK-NEXT: Other: 0 135// CHECK-NEXT: Section: .tbss 136// CHECK-NEXT: } 137// CHECK-NEXT: Symbol { 138// CHECK-NEXT: Name: b 139// CHECK-NEXT: Value: 0x0 140// CHECK-NEXT: Size: 141// CHECK-NEXT: Binding: Global 142// CHECK-NEXT: Type: TLS 143// CHECK-NEXT: Other: 0 144// CHECK-NEXT: Section: .tdata 145// CHECK-NEXT: } 146// CHECK-NEXT: Symbol { 147// CHECK-NEXT: Name: c 148// CHECK-NEXT: Value: 0xC 149// CHECK-NEXT: Size: 150// CHECK-NEXT: Binding: Global 151// CHECK-NEXT: Type: TLS 152// CHECK-NEXT: Other: 0 153// CHECK-NEXT: Section: .thread_bss 154// CHECK-NEXT: } 155// CHECK-NEXT: Symbol { 156// CHECK-NEXT: Name: d 157// CHECK-NEXT: Value: 0x4 158// CHECK-NEXT: Size: 159// CHECK-NEXT: Binding: Global 160// CHECK-NEXT: Type: TLS 161// CHECK-NEXT: Other: 0 162// CHECK-NEXT: Section: .thread_data 163// CHECK-NEXT: } 164 165// DIS: Disassembly of section .text: 166// DIS-EMPTY: 167// DIS-NEXT: <_start>: 168// DIS-NEXT: movl %fs:-8, %eax 169// DIS-NEXT: movl %fs:-16, %eax 170// DIS-NEXT: movl %fs:-4, %eax 171// DIS-NEXT: movl %fs:-12, %eax 172