1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-unknown-linux %s -o %t.o
3# RUN: ld.lld %t.o -o %t1
4# RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=RELOC %s
5# RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s
6
7## There is no relocations.
8# RELOC:    Relocations [
9# RELOC:    ]
10
11# 0x201173 + 7 - 10 = 0x201170
12# 0x20117a + 7 - 17 = 0x201170
13# 0x201181 + 7 - 23 = 0x201171
14# 0x201188 + 7 - 30 = 0x201171
15# DISASM:      Disassembly of section .text:
16# DISASM-EMPTY:
17# DISASM-NEXT: <foo>:
18# DISASM-NEXT:   201170: 90 nop
19# DISASM:      <hid>:
20# DISASM-NEXT:   201171: 90 nop
21# DISASM:      <ifunc>:
22# DISASM-NEXT:   201172: c3 retq
23# DISASM:      <_start>:
24# DISASM-NEXT: leaq -10(%rip), %rax
25# DISASM-NEXT: leaq -17(%rip), %rax
26# DISASM-NEXT: leaq -23(%rip), %rax
27# DISASM-NEXT: leaq -30(%rip), %rax
28# DISASM-NEXT: movq 4234(%rip), %rax
29# DISASM-NEXT: movq 4227(%rip), %rax
30# DISASM-NEXT: leaq -52(%rip), %rax
31# DISASM-NEXT: leaq -59(%rip), %rax
32# DISASM-NEXT: leaq -65(%rip), %rax
33# DISASM-NEXT: leaq -72(%rip), %rax
34# DISASM-NEXT: movq 4192(%rip), %rax
35# DISASM-NEXT: movq 4185(%rip), %rax
36# DISASM-NEXT: callq 0x201170 <foo>
37# DISASM-NEXT: callq 0x201170 <foo>
38# DISASM-NEXT: callq 0x201171 <hid>
39# DISASM-NEXT: callq 0x201171 <hid>
40# DISASM-NEXT: callq *4155(%rip)
41# DISASM-NEXT: callq *4149(%rip)
42# DISASM-NEXT: jmp   0x201170 <foo>
43# DISASM-NEXT: nop
44# DISASM-NEXT: jmp   0x201170 <foo>
45# DISASM-NEXT: nop
46# DISASM-NEXT: jmp   0x201171 <hid>
47# DISASM-NEXT: nop
48# DISASM-NEXT: jmp   0x201171 <hid>
49# DISASM-NEXT: nop
50# DISASM-NEXT: jmpq  *4119(%rip)
51# DISASM-NEXT: jmpq  *4113(%rip)
52
53.text
54.globl foo
55.type foo, @function
56foo:
57 nop
58
59.globl hid
60.hidden hid
61.type hid, @function
62hid:
63 nop
64
65.text
66.type ifunc STT_GNU_IFUNC
67.globl ifunc
68.type ifunc, @function
69ifunc:
70 ret
71
72.globl _start
73.type _start, @function
74_start:
75 movq foo@GOTPCREL(%rip), %rax
76 movq foo@GOTPCREL(%rip), %rax
77 movq hid@GOTPCREL(%rip), %rax
78 movq hid@GOTPCREL(%rip), %rax
79 movq ifunc@GOTPCREL(%rip), %rax
80 movq ifunc@GOTPCREL(%rip), %rax
81 movq foo@GOTPCREL(%rip), %rax
82 movq foo@GOTPCREL(%rip), %rax
83 movq hid@GOTPCREL(%rip), %rax
84 movq hid@GOTPCREL(%rip), %rax
85 movq ifunc@GOTPCREL(%rip), %rax
86 movq ifunc@GOTPCREL(%rip), %rax
87
88 call *foo@GOTPCREL(%rip)
89 call *foo@GOTPCREL(%rip)
90 call *hid@GOTPCREL(%rip)
91 call *hid@GOTPCREL(%rip)
92 call *ifunc@GOTPCREL(%rip)
93 call *ifunc@GOTPCREL(%rip)
94 jmp *foo@GOTPCREL(%rip)
95 jmp *foo@GOTPCREL(%rip)
96 jmp *hid@GOTPCREL(%rip)
97 jmp *hid@GOTPCREL(%rip)
98 jmp *ifunc@GOTPCREL(%rip)
99 jmp *ifunc@GOTPCREL(%rip)
100