Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 1 | // REQUIRES: x86 |
| 2 | // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t |
George Rimar | d46753e | 2017-10-06 09:37:44 | [diff] [blame] | 3 | // RUN: ld.lld --hash-style=sysv -shared %t -o %tout |
Fangrui Song | b159906 | 2019-05-01 05:49:01 | [diff] [blame] | 4 | // RUN: llvm-readobj --sections -r %tout | FileCheck %s |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 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. Spencer | a5d9d1f | 2015-11-11 01:27:58 | [diff] [blame] | 11 | leaq a@dtpoff(%rax), %rcx |
| 12 | leaq b@dtpoff(%rax), %rcx |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 13 | .long b@dtpoff, 0 |
Michael J. Spencer | 627ae70 | 2015-11-13 00:28:34 | [diff] [blame] | 14 | leaq c@tlsgd(%rip), %rdi |
| 15 | rex64 |
| 16 | callq __tls_get_addr@PLT |
Rafael Espindola | e02f4df | 2016-03-08 21:17:31 | [diff] [blame] | 17 | leaq a@dtpoff(%rax), %rcx |
George Rimar | 90cd0a8 | 2015-12-01 19:20:26 | [diff] [blame] | 18 | // Initial Exec Model Code Sequence, II |
| 19 | movq c@gottpoff(%rip),%rax |
| 20 | movq %fs:(%rax),%rax |
Rafael Espindola | 9644990 | 2016-02-10 16:26:31 | [diff] [blame] | 21 | movabs $a@dtpoff, %rax |
| 22 | movabs $b@dtpoff, %rax |
Rafael Espindola | e02f4df | 2016-03-08 21:17:31 | [diff] [blame] | 23 | movabs $a@dtpoff, %rax |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 24 | |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 25 | .global a |
Michael J. Spencer | a5d9d1f | 2015-11-11 01:27:58 | [diff] [blame] | 26 | .hidden a |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 27 | .section .tbss,"awT",@nobits |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 28 | .align 4 |
| 29 | a: |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 30 | .long 0 |
Michael J. Spencer | dc9c5df | 2015-11-11 01:28:23 | [diff] [blame] | 31 | |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 32 | .section .tbss,"awT",@nobits |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 33 | .align 4 |
| 34 | b: |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 35 | .long 0 |
Michael J. Spencer | 627ae70 | 2015-11-13 00:28:34 | [diff] [blame] | 36 | .global c |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 37 | .section .tbss,"awT",@nobits |
Michael J. Spencer | 627ae70 | 2015-11-13 00:28:34 | [diff] [blame] | 38 | .align 4 |
| 39 | c: |
Rui Ueyama | 8486a51 | 2015-11-20 22:47:40 | [diff] [blame] | 40 | .long 0 |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 41 | |
Michael J. Spencer | 627ae70 | 2015-11-13 00:28:34 | [diff] [blame] | 42 | // Get the address of the got, and check that it has 4 entries. |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 43 | |
| 44 | // CHECK: Sections [ |
Peter Collingbourne | 628ec9f | 2017-01-10 01:21:30 | [diff] [blame] | 45 | // CHECK: Name: .got ( |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 46 | // CHECK-NEXT: Type: SHT_PROGBITS |
| 47 | // CHECK-NEXT: Flags [ |
| 48 | // CHECK-NEXT: SHF_ALLOC |
| 49 | // CHECK-NEXT: SHF_WRITE |
| 50 | // CHECK-NEXT: ] |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 51 | // CHECK-NEXT: Address: 0x20E0 |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 52 | // CHECK-NEXT: Offset: |
George Rimar | 90cd0a8 | 2015-12-01 19:20:26 | [diff] [blame] | 53 | // CHECK-NEXT: Size: 40 |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 54 | |
| 55 | // CHECK: Relocations [ |
| 56 | // CHECK: Section ({{.+}}) .rela.dyn { |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 57 | // 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. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 61 | // CHECK-NEXT: } |
| 62 | |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 63 | // 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. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 67 | |
| 68 | // DIS: Disassembly of section .text: |
Fangrui Song | 5387c2c | 2019-05-01 10:40:48 | [diff] [blame^] | 69 | // DIS-EMPTY: |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 70 | // DIS-NEXT: .text: |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 71 | // DIS-NEXT: 1000: {{.+}} leaq 4313(%rip), %rdi |
Michael J. Spencer | 1e22561 | 2015-11-11 01:00:24 | [diff] [blame] | 72 | // DIS-NEXT: 1007: {{.+}} callq |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 73 | // DIS-NEXT: 100c: {{.+}} leaq 4301(%rip), %rdi |
Michael J. Spencer | a5d9d1f | 2015-11-11 01:27:58 | [diff] [blame] | 74 | // DIS-NEXT: 1013: {{.+}} callq |
| 75 | // DIS-NEXT: 1018: {{.+}} leaq (%rax), %rcx |
| 76 | // DIS-NEXT: 101f: {{.+}} leaq 4(%rax), %rcx |
Michael J. Spencer | ac2307b | 2015-11-11 01:28:11 | [diff] [blame] | 77 | // DIS-NEXT: 1026: 04 00 |
| 78 | // DIS-NEXT: 1028: 00 00 |
| 79 | // DIS-NEXT: 102a: 00 00 |
| 80 | // DIS-NEXT: 102c: 00 00 |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 81 | // DIS-NEXT: 102e: {{.+}} leaq 4283(%rip), %rdi |
Michael J. Spencer | 627ae70 | 2015-11-13 00:28:34 | [diff] [blame] | 82 | // DIS-NEXT: 1035: {{.+}} callq |
Rafael Espindola | e02f4df | 2016-03-08 21:17:31 | [diff] [blame] | 83 | // DIS-NEXT: 103b: {{.+}} leaq (%rax), %rcx |
Fangrui Song | 07f8daf | 2019-03-14 03:47:45 | [diff] [blame] | 84 | // DIS-NEXT: 1042: {{.+}} movq 4279(%rip), %rax |
George Rimar | 90cd0a8 | 2015-12-01 19:20:26 | [diff] [blame] | 85 | // DIS-NEXT: 1049: {{.+}} movq %fs:(%rax), %rax |
Rafael Espindola | 9644990 | 2016-02-10 16:26:31 | [diff] [blame] | 86 | // DIS-NEXT: 104d: {{.+}} movabsq $0, %rax |
| 87 | // DIS-NEXT: 1057: {{.+}} movabsq $4, %rax |
Rafael Espindola | e02f4df | 2016-03-08 21:17:31 | [diff] [blame] | 88 | // DIS-NEXT: 1061: {{.+}} movabsq $0, %rax |