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/// Reject local-exec TLS relocations for -shared, regardless of the preemptibility. 8// RUN: not ld.lld -shared %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR 9// RUN: not ld.lld -shared -Bsymbolic %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR 10 11// ERR: error: relocation R_X86_64_TPOFF32 against a cannot be used with -shared 12// ERR-NEXT: defined in {{.*}} 13// ERR-NEXT: referenced by {{.*}}:(.text+0x4) 14// ERR-EMPTY: 15// ERR-NEXT: error: relocation R_X86_64_TPOFF32 against b cannot be used with -shared 16// ERR-NEXT: defined in {{.*}} 17// ERR-NEXT: referenced by {{.*}}:(.text+0xC) 18// ERR-EMPTY: 19// ERR-NEXT: error: relocation R_X86_64_TPOFF32 against c cannot be used with -shared 20// ERR-NEXT: defined in {{.*}} 21// ERR-NEXT: referenced by {{.*}}:(.text+0x14) 22// ERR-EMPTY: 23// ERR-NEXT: error: relocation R_X86_64_TPOFF32 against d cannot be used with -shared 24// ERR-NEXT: defined in {{.*}} 25// ERR-NEXT: referenced by {{.*}}:(.text+0x1C) 26 27.global _start 28_start: 29 movl %fs:a@tpoff, %eax 30 movl %fs:b@tpoff, %eax 31 movl %fs:c@tpoff, %eax 32 movl %fs:d@tpoff, %eax 33 34 .global a 35 .section .tbss,"awT",@nobits 36a: 37 .long 0 38 39 .global b 40 .section .tdata,"awT",@progbits 41b: 42 .long 1 43 44 .global c 45 .section .thread_bss,"awT",@nobits 46c: 47 .long 0 48 49 .global d 50 .section .thread_data,"awT",@progbits 51d: 52 .long 2 53 54// CHECK: Name: .tdata 55// CHECK-NEXT: Type: SHT_PROGBITS 56// CHECK-NEXT: Flags [ 57// CHECK-NEXT: SHF_ALLOC 58// CHECK-NEXT: SHF_TLS 59// CHECK-NEXT: SHF_WRITE 60// CHECK-NEXT: ] 61// CHECK-NEXT: Address: [[TDATA_ADDR:0x.*]] 62// CHECK-NEXT: Offset: 63// CHECK-NEXT: Size: 4 64// CHECK-NEXT: Link: 65// CHECK-NEXT: Info: 66// CHECK-NEXT: AddressAlignment: 67// CHECK-NEXT: EntrySize: 68// CHECK-NEXT: } 69// CHECK-NEXT: Section { 70// CHECK-NEXT: Index: 71// CHECK-NEXT: Name: .thread_data 72// CHECK-NEXT: Type: SHT_PROGBITS 73// CHECK-NEXT: Flags [ 74// CHECK-NEXT: SHF_ALLOC 75// CHECK-NEXT: SHF_TLS 76// CHECK-NEXT: SHF_WRITE 77// CHECK-NEXT: ] 78// CHECK-NEXT: Address: 79// CHECK-NEXT: Offset: 80// CHECK-NEXT: Size: 4 81// CHECK-NEXT: Link: 82// CHECK-NEXT: Info: 83// CHECK-NEXT: AddressAlignment: 84// CHECK-NEXT: EntrySize: 85// CHECK-NEXT: } 86// CHECK-NEXT: Section { 87// CHECK-NEXT: Index: 88// CHECK-NEXT: Name: .tbss 89// CHECK-NEXT: Type: SHT_NOBITS 90// CHECK-NEXT: Flags [ 91// CHECK-NEXT: SHF_ALLOC 92// CHECK-NEXT: SHF_TLS 93// CHECK-NEXT: SHF_WRITE 94// CHECK-NEXT: ] 95// CHECK-NEXT: Address: [[TBSS_ADDR:0x.*]] 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// CHECK-NEXT: Section { 104// CHECK-NEXT: Index: 105// CHECK-NEXT: Name: .thread_bss 106// CHECK-NEXT: Type: SHT_NOBITS 107// CHECK-NEXT: Flags [ 108// CHECK-NEXT: SHF_ALLOC 109// CHECK-NEXT: SHF_TLS 110// CHECK-NEXT: SHF_WRITE 111// CHECK-NEXT: ] 112 113// 0x2021F4 = TBSS_ADDR + 4 114 115// CHECK-NEXT: Address: 0x2021F4 116// CHECK-NEXT: Offset: 117// CHECK-NEXT: Size: 4 118// CHECK-NEXT: Link: 119// CHECK-NEXT: Info: 120// CHECK-NEXT: AddressAlignment: 121// CHECK-NEXT: EntrySize: 122// CHECK-NEXT: } 123 124// Check that the TLS NOBITS sections weren't added to the R/W PT_LOAD's size. 125 126// CHECK: ProgramHeaders [ 127// CHECK: Type: PT_LOAD 128// CHECK: Type: PT_LOAD 129// CHECK: Type: PT_LOAD 130// CHECK: FileSize: 8 131// CHECK-NEXT: MemSize: 8 132// CHECK-NEXT: Flags [ 133// CHECK-NEXT: PF_R 134// CHECK-NEXT: PF_W 135// CHECK-NEXT: ] 136// CHECK: Type: PT_TLS 137// CHECK-NEXT: Offset: 138// CHECK-NEXT: VirtualAddress: [[TDATA_ADDR]] 139// CHECK-NEXT: PhysicalAddress: [[TDATA_ADDR]] 140// CHECK-NEXT: FileSize: 8 141// CHECK-NEXT: MemSize: 16 142// CHECK-NEXT: Flags [ 143// CHECK-NEXT: PF_R 144// CHECK-NEXT: ] 145// CHECK-NEXT: Alignment: 146// CHECK-NEXT: } 147 148// CHECK: Symbols [ 149// CHECK: Name: a 150// CHECK-NEXT: Value: 0x8 151// CHECK-NEXT: Size: 152// CHECK-NEXT: Binding: Global 153// CHECK-NEXT: Type: TLS 154// CHECK-NEXT: Other: 0 155// CHECK-NEXT: Section: .tbss 156// CHECK-NEXT: } 157// CHECK-NEXT: Symbol { 158// CHECK-NEXT: Name: b 159// CHECK-NEXT: Value: 0x0 160// CHECK-NEXT: Size: 161// CHECK-NEXT: Binding: Global 162// CHECK-NEXT: Type: TLS 163// CHECK-NEXT: Other: 0 164// CHECK-NEXT: Section: .tdata 165// CHECK-NEXT: } 166// CHECK-NEXT: Symbol { 167// CHECK-NEXT: Name: c 168// CHECK-NEXT: Value: 0xC 169// CHECK-NEXT: Size: 170// CHECK-NEXT: Binding: Global 171// CHECK-NEXT: Type: TLS 172// CHECK-NEXT: Other: 0 173// CHECK-NEXT: Section: .thread_bss 174// CHECK-NEXT: } 175// CHECK-NEXT: Symbol { 176// CHECK-NEXT: Name: d 177// CHECK-NEXT: Value: 0x4 178// CHECK-NEXT: Size: 179// CHECK-NEXT: Binding: Global 180// CHECK-NEXT: Type: TLS 181// CHECK-NEXT: Other: 0 182// CHECK-NEXT: Section: .thread_data 183// CHECK-NEXT: } 184 185// DIS: Disassembly of section .text: 186// DIS-EMPTY: 187// DIS-NEXT: <_start>: 188// DIS-NEXT: movl %fs:-8, %eax 189// DIS-NEXT: movl %fs:-16, %eax 190// DIS-NEXT: movl %fs:-4, %eax 191// DIS-NEXT: movl %fs:-12, %eax 192