• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
3// RUN: ld.lld %t.o -o %t1
4// RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=NORELOC %s
5// RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s
6
7// NORELOC:      Relocations [
8// NORELOC-NEXT: ]
9
10// DISASM:      Disassembly of section .text:
11// DISASM-EMPTY:
12// DISASM-NEXT: <_start>:
13// LD -> LE:
14// DISASM-NEXT: 4010f4: 65 a1 00 00 00 00 movl %gs:0, %eax
15// DISASM-NEXT: 4010fa: 90                nop
16// DISASM-NEXT: 4010fb: 8d 74 26 00       leal (%esi,%eiz), %esi
17// DISASM-NEXT: 4010ff: 8d 90 f8 ff ff ff leal -8(%eax), %edx
18// DISASM-NEXT: 401105: 65 a1 00 00 00 00 movl %gs:0, %eax
19// DISASM-NEXT: 40110b: 90                nop
20// DISASM-NEXT: 40110c: 8d 74 26 00       leal (%esi,%eiz), %esi
21// DISASM-NEXT: 401110: 8d 90 fc ff ff ff leal -4(%eax), %edx
22// IE -> LE:
23// 4294967288 == 0xFFFFFFF8
24// 4294967292 == 0xFFFFFFFC
25// DISASM-NEXT: 401116: 65 a1 00 00 00 00  movl %gs:0, %eax
26// DISASM-NEXT: 40111c: c7 c0 f8 ff ff ff  movl $4294967288, %eax
27// DISASM-NEXT: 401122: 65 a1 00 00 00 00  movl %gs:0, %eax
28// DISASM-NEXT: 401128: c7 c0 fc ff ff ff  movl $4294967292, %eax
29// DISASM-NEXT: 40112e: 65 a1 00 00 00 00  movl %gs:0, %eax
30// DISASM-NEXT: 401134: 8d 80 f8 ff ff ff  leal -8(%eax), %eax
31// DISASM-NEXT: 40113a: 65 a1 00 00 00 00  movl %gs:0, %eax
32// DISASM-NEXT: 401140: 8d 80 fc ff ff ff  leal -4(%eax), %eax
33.type tls0,@object
34.section .tbss,"awT",@nobits
35.globl tls0
36.align 4
37tls0:
38 .long 0
39 .size tls0, 4
40
41.type  tls1,@object
42.globl tls1
43.align 4
44tls1:
45 .long 0
46 .size tls1, 4
47
48.section .text
49.globl ___tls_get_addr
50.type ___tls_get_addr,@function
51___tls_get_addr:
52
53.section .text
54.globl _start
55_start:
56//LD -> LE:
57leal tls0@tlsldm(%ebx),%eax
58call ___tls_get_addr@plt
59leal tls0@dtpoff(%eax),%edx
60leal tls1@tlsldm(%ebx),%eax
61call ___tls_get_addr@plt
62leal tls1@dtpoff(%eax),%edx
63//IE -> LE:
64movl %gs:0,%eax
65movl tls0@gotntpoff(%ebx),%eax
66movl %gs:0,%eax
67movl tls1@gotntpoff(%ebx),%eax
68movl %gs:0,%eax
69addl tls0@gotntpoff(%ebx),%eax
70movl %gs:0,%eax
71addl tls1@gotntpoff(%ebx),%eax
72