blob: 9074be5fdaab10bbf4bbe8fc9faafaf4e32297b6 [file] [log] [blame]
Michael J. Spencer1e225612015-11-11 01:00:241// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3// RUN: ld.lld2 -shared %t -o %tout
4// RUN: llvm-readobj -sections -relocations %tout | FileCheck %s
5// RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS
6
7 leaq a@tlsld(%rip), %rdi
8 callq __tls_get_addr@PLT
9 leaq b@tlsld(%rip), %rdi
10 callq __tls_get_addr@PLT
Michael J. Spencera5d9d1f2015-11-11 01:27:5811 leaq a@dtpoff(%rax), %rcx
12 leaq b@dtpoff(%rax), %rcx
Michael J. Spencer1e225612015-11-11 01:00:2413
14 .global a
Michael J. Spencera5d9d1f2015-11-11 01:27:5815 .hidden a
Michael J. Spencer1e225612015-11-11 01:00:2416 .section .tbss,"awT",@nobits
17 .align 4
18a:
19 .long 0
20
21 .global b
Michael J. Spencera5d9d1f2015-11-11 01:27:5822 .hidden b
Michael J. Spencer1e225612015-11-11 01:00:2423 .section .tbss,"awT",@nobits
24 .align 4
25b:
26 .long 0
27
28// Get the address of the got, and check that it has two entries.
29
30// CHECK: Sections [
31// CHECK: Name: .got
32// CHECK-NEXT: Type: SHT_PROGBITS
33// CHECK-NEXT: Flags [
34// CHECK-NEXT: SHF_ALLOC
35// CHECK-NEXT: SHF_WRITE
36// CHECK-NEXT: ]
37// CHECK-NEXT: Address: 0x20D0
38// CHECK-NEXT: Offset:
39// CHECK-NEXT: Size: 16
40
41// CHECK: Relocations [
42// CHECK: Section ({{.+}}) .rela.dyn {
43// CHECK-NEXT: 0x20D0 R_X86_64_DTPMOD64 - 0x0
44// CHECK-NEXT: }
45
46// 4297 = (0x20D0 + -4) - (0x1000 + 3) // PC relative offset to got entry.
Michael J. Spencera5d9d1f2015-11-11 01:27:5847// 4285 = (0x20D0 + -4) - (0x100c + 3) // PC relative offset to got entry.
Michael J. Spencer1e225612015-11-11 01:00:2448
49// DIS: Disassembly of section .text:
50// DIS-NEXT: .text:
51// DIS-NEXT: 1000: {{.+}} leaq 4297(%rip), %rdi
52// DIS-NEXT: 1007: {{.+}} callq
53// DIS-NEXT: 100c: {{.+}} leaq 4285(%rip), %rdi
Michael J. Spencera5d9d1f2015-11-11 01:27:5854// DIS-NEXT: 1013: {{.+}} callq
55// DIS-NEXT: 1018: {{.+}} leaq (%rax), %rcx
56// DIS-NEXT: 101f: {{.+}} leaq 4(%rax), %rcx