blob: 910a7d2db4c44566029a9c0441d6ae50b0eaa1ed [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 Songd4306e92019-09-16 07:05:3451// CHECK-NEXT: Address: 0x24A0
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 Songd4306e92019-09-16 07:05:3457// CHECK-NEXT: 0x24A0 R_X86_64_DTPMOD64 - 0x0
58// CHECK-NEXT: 0x24B0 R_X86_64_DTPMOD64 c 0x0
59// CHECK-NEXT: 0x24B8 R_X86_64_DTPOFF64 c 0x0
60// CHECK-NEXT: 0x24C0 R_X86_64_TPOFF64 c 0x0
Michael J. Spencer1e225612015-11-11 01:00:2461// CHECK-NEXT: }
62
Fangrui Songd4306e92019-09-16 07:05:3463// 4457 = (0x24A0 + -4) - (0x1330 + 3) // PC relative offset to got entry.
64// 4445 = (0x24B0 + -4) - (0x133c + 3) // PC relative offset to got entry.
65// 4427 = (0x24B8 + -4) - (0x135e + 3) // PC relative offset to got entry.
66// 4423 = (0x24C0 + -4) - (0x1372 + 3) // PC relative offset to got entry.
Michael J. Spencer1e225612015-11-11 01:00:2467
68// DIS: Disassembly of section .text:
Fangrui Song5387c2c2019-05-01 10:40:4869// DIS-EMPTY:
Fangrui Song71e2ca62020-03-05 22:18:3870// DIS-NEXT: <.text>:
Fangrui Songd4306e92019-09-16 07:05:3471// DIS-NEXT: 1330: {{.+}} leaq 4457(%rip), %rdi
Fangrui Song0e798902019-09-07 10:42:1172// DIS-NEXT: {{.+}} callq
Fangrui Songd4306e92019-09-16 07:05:3473// DIS-NEXT: 133c: {{.+}} leaq 4445(%rip), %rdi
Fangrui Song0e798902019-09-07 10:42:1174// DIS-NEXT: {{.+}} callq
75// DIS-NEXT: {{.+}} leaq (%rax), %rcx
76// DIS-NEXT: {{.+}} leaq 4(%rax), %rcx
77// DIS-NEXT: 04 00
78// DIS-NEXT: 00 00
79// DIS-NEXT: 00 00
80// DIS-NEXT: 00 00
Fangrui Songd4306e92019-09-16 07:05:3481// DIS-NEXT: 135e: {{.+}} leaq 4427(%rip), %rdi
Fangrui Song0e798902019-09-07 10:42:1182// DIS-NEXT: {{.+}} callq
83// DIS-NEXT: {{.+}} leaq (%rax), %rcx
Fangrui Songd4306e92019-09-16 07:05:3484// DIS-NEXT: 1372: {{.+}} movq 4423(%rip), %rax
Fangrui Song0e798902019-09-07 10:42:1185// DIS-NEXT: {{.+}} movq %fs:(%rax), %rax
86// DIS-NEXT: {{.+}} movabsq $0, %rax
87// DIS-NEXT: {{.+}} movabsq $4, %rax
88// DIS-NEXT: {{.+}} movabsq $0, %rax