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 %tout | FileCheck --check-prefixes=CHECK,CHECK1 %s
5// RUN: echo "SECTIONS { \
6// RUN:   . = 0x201000; \
7// RUN:   .text : { *(.text) } \
8// RUN:   . = 0x202000; \
9// RUN:   .tdata : { *(.tdata) } \
10// RUN:   .tbss : { *(.tbss) } \
11// RUN:   .data.rel.ro : { *(.data.rel.ro) } \
12// RUN: }" > %t.script
13// RUN: ld.lld -T %t.script %t -o %tout2
14// RUN: llvm-readobj -S %tout2 | FileCheck --check-prefixes=CHECK,CHECK2 %s
15        .global _start
16_start:
17        retq
18
19        .section        .tdata,"awT",@progbits
20        .align  4
21        .long   42
22
23        .section        .tbss,"awT",@nobits
24        .align  16
25        .zero 16
26
27        .section        .data.rel.ro,"aw",@progbits
28        .long 1
29
30
31// Test that .tbss doesn't show up in the offset or in the address. If this
32// gets out of sync what we get a runtime is different from what the section
33// table says.
34
35// CHECK:       Name: .tdata
36// CHECK-NEXT:  Type: SHT_PROGBITS
37// CHECK-NEXT:  Flags [
38// CHECK-NEXT:    SHF_ALLOC
39// CHECK-NEXT:    SHF_TLS
40// CHECK-NEXT:    SHF_WRITE
41// CHECK-NEXT:  ]
42// CHECK1-NEXT: Address: 0x2021D0
43// CHECK1-NEXT: Offset: 0x1D0
44// CHECK2-NEXT: Address: 0x202000
45// CHECK2-NEXT: Offset: 0x2000
46// CHECK-NEXT:  Size: 4
47
48// CHECK:       Name: .tbss
49// CHECK-NEXT:  Type: SHT_NOBITS
50// CHECK-NEXT:  Flags [
51// CHECK-NEXT:    SHF_ALLOC
52// CHECK-NEXT:    SHF_TLS
53// CHECK-NEXT:    SHF_WRITE
54// CHECK-NEXT:  ]
55// CHECK1-NEXT: Address: 0x2021E0
56// CHECK1-NEXT: Offset: 0x1D4
57// CHECK2-NEXT: Address: 0x202010
58// CHECK2-NEXT: Offset: 0x2004
59// CHECK-NEXT:  Size: 16
60
61// CHECK:       Name: .data.rel.ro
62// CHECK-NEXT:  Type: SHT_PROGBITS
63// CHECK-NEXT:  Flags [
64// CHECK-NEXT:    SHF_ALLOC
65// CHECK-NEXT:    SHF_WRITE
66// CHECK-NEXT:  ]
67// CHECK1-NEXT: Address: 0x2021D4
68// CHECK1-NEXT: Offset: 0x1D4
69// CHECK2-NEXT: Address: 0x202004
70// CHECK2-NEXT: Offset: 0x2004
71// CHECK-NEXT:  Size: 4
72