2015-10-28 05:22:54 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld %t -o %tout
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --symbols --sections -l %tout | FileCheck %s
|
2015-11-04 06:39:09 +08:00
|
|
|
// RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS
|
2015-10-28 05:22:54 +08:00
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
2015-11-04 06:39:09 +08:00
|
|
|
movl %fs:a@tpoff, %eax
|
|
|
|
movl %fs:b@tpoff, %eax
|
|
|
|
movl %fs:c@tpoff, %eax
|
|
|
|
movl %fs:d@tpoff, %eax
|
2015-10-28 05:22:54 +08:00
|
|
|
|
2015-11-04 06:39:09 +08:00
|
|
|
.global a
|
2015-10-28 05:22:54 +08:00
|
|
|
.section .tbss,"awT",@nobits
|
2015-11-04 06:39:09 +08:00
|
|
|
a:
|
2015-10-28 05:22:54 +08:00
|
|
|
.long 0
|
|
|
|
|
2015-11-04 06:39:09 +08:00
|
|
|
.global b
|
2015-10-28 05:22:54 +08:00
|
|
|
.section .tdata,"awT",@progbits
|
2015-11-04 06:39:09 +08:00
|
|
|
b:
|
2015-10-28 05:22:54 +08:00
|
|
|
.long 1
|
|
|
|
|
2015-11-04 06:39:09 +08:00
|
|
|
.global c
|
2015-10-28 05:22:54 +08:00
|
|
|
.section .thread_bss,"awT",@nobits
|
2015-11-04 06:39:09 +08:00
|
|
|
c:
|
2015-10-28 05:22:54 +08:00
|
|
|
.long 0
|
|
|
|
|
2015-11-04 06:39:09 +08:00
|
|
|
.global d
|
2015-10-28 05:22:54 +08:00
|
|
|
.section .thread_data,"awT",@progbits
|
2015-11-04 06:39:09 +08:00
|
|
|
d:
|
2015-10-28 05:22:54 +08:00
|
|
|
.long 2
|
|
|
|
|
|
|
|
// CHECK: Name: .tdata
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_TLS
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
2015-11-03 08:34:39 +08:00
|
|
|
// CHECK-NEXT: Address: [[TDATA_ADDR:0x.*]]
|
2015-10-28 05:22:54 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize:
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section {
|
|
|
|
// CHECK-NEXT: Index:
|
|
|
|
// CHECK-NEXT: Name: .thread_data
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_TLS
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address:
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize:
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section {
|
|
|
|
// CHECK-NEXT: Index:
|
|
|
|
// CHECK-NEXT: Name: .tbss
|
|
|
|
// CHECK-NEXT: Type: SHT_NOBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_TLS
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
2015-11-03 08:34:39 +08:00
|
|
|
// CHECK-NEXT: Address: [[TBSS_ADDR:0x.*]]
|
2015-10-28 05:22:54 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize:
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section {
|
|
|
|
// CHECK-NEXT: Index:
|
|
|
|
// CHECK-NEXT: Name: .thread_bss
|
|
|
|
// CHECK-NEXT: Type: SHT_NOBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_TLS
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
2015-11-03 08:34:39 +08:00
|
|
|
|
2016-11-24 01:44:02 +08:00
|
|
|
// 0x20200C = TBSS_ADDR + 4
|
2015-11-03 08:34:39 +08:00
|
|
|
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Address: 0x20200C
|
2015-10-28 05:22:54 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: 4
|
2015-11-03 08:34:39 +08:00
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize:
|
|
|
|
// CHECK-NEXT: }
|
2015-10-28 05:22:54 +08:00
|
|
|
|
2015-11-04 06:39:09 +08:00
|
|
|
// CHECK: Symbols [
|
|
|
|
// CHECK: Name: a
|
|
|
|
// CHECK-NEXT: Value: 0x8
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: TLS
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .tbss
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: b
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: TLS
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .tdata
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: c
|
|
|
|
// CHECK-NEXT: Value: 0xC
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: TLS
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .thread_bss
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: d
|
|
|
|
// CHECK-NEXT: Value: 0x4
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: TLS
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .thread_data
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2015-10-28 05:22:54 +08:00
|
|
|
// Check that the TLS NOBITS sections weren't added to the R/W PT_LOAD's size.
|
|
|
|
|
|
|
|
// CHECK: ProgramHeaders [
|
|
|
|
// CHECK: Type: PT_LOAD
|
|
|
|
// CHECK: Type: PT_LOAD
|
2015-11-04 06:39:09 +08:00
|
|
|
// CHECK: Type: PT_LOAD
|
2015-10-28 05:22:54 +08:00
|
|
|
// CHECK: FileSize: 8
|
|
|
|
// CHECK-NEXT: MemSize: 8
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: PF_R
|
|
|
|
// CHECK-NEXT: PF_W
|
|
|
|
// CHECK-NEXT: ]
|
2015-11-03 08:34:39 +08:00
|
|
|
// CHECK: Type: PT_TLS
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: VirtualAddress: [[TDATA_ADDR]]
|
|
|
|
// CHECK-NEXT: PhysicalAddress: [[TDATA_ADDR]]
|
|
|
|
// CHECK-NEXT: FileSize: 8
|
|
|
|
// CHECK-NEXT: MemSize: 16
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: PF_R
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Alignment:
|
|
|
|
// CHECK-NEXT: }
|
2015-11-04 06:39:09 +08:00
|
|
|
|
|
|
|
// DIS: Disassembly of section .text:
|
|
|
|
// DIS-NEXT: _start:
|
2016-11-24 01:44:02 +08:00
|
|
|
// DIS-NEXT: 201000: {{.+}} movl %fs:-8, %eax
|
|
|
|
// DIS-NEXT: 201008: {{.+}} movl %fs:-16, %eax
|
|
|
|
// DIS-NEXT: 201010: {{.+}} movl %fs:-4, %eax
|
|
|
|
// DIS-NEXT: 201018: {{.+}} movl %fs:-12, %eax
|