blob: d7c2e1f55b672ee36d0434d5e364154449b01c60 [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
George Rimard46753e2017-10-06 09:37:443// RUN: ld.lld --hash-style=sysv -shared %t -o %tout
Fangrui Songb1599062019-05-01 05:49:014// RUN: llvm-readobj --sections -r %tout | FileCheck %s
Michael J. Spencer1e225612015-11-11 01:00:245// 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
Rui Ueyama8486a512015-11-20 22:47:4013 .long b@dtpoff, 0
Michael J. Spencer627ae702015-11-13 00:28:3414 leaq c@tlsgd(%rip), %rdi
15 rex64
16 callq __tls_get_addr@PLT
Rafael Espindolae02f4df2016-03-08 21:17:3117 leaq a@dtpoff(%rax), %rcx
George Rimar90cd0a82015-12-01 19:20:2618 // Initial Exec Model Code Sequence, II
19 movq c@gottpoff(%rip),%rax
20 movq %fs:(%rax),%rax
Rafael Espindola96449902016-02-10 16:26:3121 movabs $a@dtpoff, %rax
22 movabs $b@dtpoff, %rax
Rafael Espindolae02f4df2016-03-08 21:17:3123 movabs $a@dtpoff, %rax
Michael J. Spencer1e225612015-11-11 01:00:2424
Rui Ueyama8486a512015-11-20 22:47:4025 .global a
Michael J. Spencera5d9d1f2015-11-11 01:27:5826 .hidden a
Rui Ueyama8486a512015-11-20 22:47:4027 .section .tbss,"awT",@nobits
Michael J. Spencer1e225612015-11-11 01:00:2428 .align 4
29a:
Rui Ueyama8486a512015-11-20 22:47:4030 .long 0
Michael J. Spencerdc9c5df2015-11-11 01:28:2331
Rui Ueyama8486a512015-11-20 22:47:4032 .section .tbss,"awT",@nobits
Michael J. Spencer1e225612015-11-11 01:00:2433 .align 4
34b:
Rui Ueyama8486a512015-11-20 22:47:4035 .long 0
Michael J. Spencer627ae702015-11-13 00:28:3436 .global c
Rui Ueyama8486a512015-11-20 22:47:4037 .section .tbss,"awT",@nobits
Michael J. Spencer627ae702015-11-13 00:28:3438 .align 4
39c:
Rui Ueyama8486a512015-11-20 22:47:4040 .long 0
Michael J. Spencer1e225612015-11-11 01:00:2441
Michael J. Spencer627ae702015-11-13 00:28:3442// Get the address of the got, and check that it has 4 entries.
Michael J. Spencer1e225612015-11-11 01:00:2443
44// CHECK: Sections [
Peter Collingbourne628ec9f2017-01-10 01:21:3045// CHECK: Name: .got (
Michael J. Spencer1e225612015-11-11 01:00:2446// CHECK-NEXT: Type: SHT_PROGBITS
47// CHECK-NEXT: Flags [
48// CHECK-NEXT: SHF_ALLOC
49// CHECK-NEXT: SHF_WRITE
50// CHECK-NEXT: ]
Fangrui Song07f8daf2019-03-14 03:47:4551// CHECK-NEXT: Address: 0x20E0
Michael J. Spencer1e225612015-11-11 01:00:2452// CHECK-NEXT: Offset:
George Rimar90cd0a82015-12-01 19:20:2653// CHECK-NEXT: Size: 40
Michael J. Spencer1e225612015-11-11 01:00:2454
55// CHECK: Relocations [
56// CHECK: Section ({{.+}}) .rela.dyn {
Fangrui Song07f8daf2019-03-14 03:47:4557// CHECK-NEXT: 0x20E0 R_X86_64_DTPMOD64 - 0x0
58// CHECK-NEXT: 0x20F0 R_X86_64_DTPMOD64 c 0x0
59// CHECK-NEXT: 0x20F8 R_X86_64_DTPOFF64 c 0x0
60// CHECK-NEXT: 0x2100 R_X86_64_TPOFF64 c 0x0
Michael J. Spencer1e225612015-11-11 01:00:2461// CHECK-NEXT: }
62
Fangrui Song07f8daf2019-03-14 03:47:4563// 4313 = (0x20E0 + -4) - (0x1000 + 3) // PC relative offset to got entry.
64// 4301 = (0x20F0 + -4) - (0x100c + 3) // PC relative offset to got entry.
65// 4283 = (0x20F8 + -4) - (0x102e + 3) // PC relative offset to got entry.
66// 4279 = (0x2100 + -4) - (0x1042 + 3) // PC relative offset to got entry.
Michael J. Spencer1e225612015-11-11 01:00:2467
68// DIS: Disassembly of section .text:
69// DIS-NEXT: .text:
Fangrui Song07f8daf2019-03-14 03:47:4570// DIS-NEXT: 1000: {{.+}} leaq 4313(%rip), %rdi
Michael J. Spencer1e225612015-11-11 01:00:2471// DIS-NEXT: 1007: {{.+}} callq
Fangrui Song07f8daf2019-03-14 03:47:4572// DIS-NEXT: 100c: {{.+}} leaq 4301(%rip), %rdi
Michael J. Spencera5d9d1f2015-11-11 01:27:5873// DIS-NEXT: 1013: {{.+}} callq
74// DIS-NEXT: 1018: {{.+}} leaq (%rax), %rcx
75// DIS-NEXT: 101f: {{.+}} leaq 4(%rax), %rcx
Michael J. Spencerac2307b2015-11-11 01:28:1176// DIS-NEXT: 1026: 04 00
77// DIS-NEXT: 1028: 00 00
78// DIS-NEXT: 102a: 00 00
79// DIS-NEXT: 102c: 00 00
Fangrui Song07f8daf2019-03-14 03:47:4580// DIS-NEXT: 102e: {{.+}} leaq 4283(%rip), %rdi
Michael J. Spencer627ae702015-11-13 00:28:3481// DIS-NEXT: 1035: {{.+}} callq
Rafael Espindolae02f4df2016-03-08 21:17:3182// DIS-NEXT: 103b: {{.+}} leaq (%rax), %rcx
Fangrui Song07f8daf2019-03-14 03:47:4583// DIS-NEXT: 1042: {{.+}} movq 4279(%rip), %rax
George Rimar90cd0a82015-12-01 19:20:2684// DIS-NEXT: 1049: {{.+}} movq %fs:(%rax), %rax
Rafael Espindola96449902016-02-10 16:26:3185// DIS-NEXT: 104d: {{.+}} movabsq $0, %rax
86// DIS-NEXT: 1057: {{.+}} movabsq $4, %rax
Rafael Espindolae02f4df2016-03-08 21:17:3187// DIS-NEXT: 1061: {{.+}} movabsq $0, %rax