1 # REQUIRES: system-linux
3 ## Check that BOLT correctly handles different types of instructions with
4 ## R_X86_64_GOTPCRELX or R_X86_64_REX_GOTPCRELX relocations and different
5 ## kinds of handling of the relocation by the linker (no relaxation, pic, and
8 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
9 # RUN: ld.lld %t.o -o %t.exe -q
10 # RUN: ld.lld %t.o -o %t.pie.exe -q -pie
11 # RUN: ld.lld %t.o -o %t.no-relax.exe -q --no-relax
12 # RUN: llvm-bolt %t.exe --relocs -o %t.out --print-cfg --print-only=_start \
13 # RUN: 2>&1 | FileCheck --check-prefix=BOLT %s
14 # RUN: llvm-bolt %t.pie.exe -o %t.null --print-cfg --print-only=_start \
15 # RUN: 2>&1 | FileCheck --check-prefix=PIE-BOLT %s
16 # RUN: llvm-bolt %t.no-relax.exe -o %t.null --print-cfg --print-only=_start \
17 # RUN: 2>&1 | FileCheck --check-prefix=NO-RELAX-BOLT %s
18 # RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
19 # RUN: %t.out | FileCheck --check-prefix=DISASM %s
21 ## Relocate foo only and check that code references from _start (that is
22 ## otherwise preserved) are updated.
24 # RUN: llvm-bolt %t.exe --relocs -o %t.lite.out --funcs=foo
25 # RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
26 # RUN: %t.lite.out | FileCheck --check-prefix=DISASM %s
30 .type _start, %function
35 call
*foo@GOTPCREL
(%rip
)
36 # NO-RELAX-BOLT: callq *{{.*}}(%rip)
39 # DISASM-NEXT: callq 0x[[#%x,ADDR:]]
41 movq foo@GOTPCREL
(%rip
), %rdi
42 # NO-RELAX-BOLT-NEXT: movq {{.*}}(%rip), %rdi
43 # BOLT-NEXT: leaq foo(%rip), %rdi
44 # PIE-BOLT-NEXT: leaq foo(%rip), %rdi
45 # DISASM-NEXT: leaq {{.*}}(%rip), %rdi # 0x[[#ADDR]]
47 movl foo@GOTPCREL+
4(%rip
), %edi
48 # NO-RELAX-BOLT-NEXT: movl {{.*}}(%rip), %edi
49 # BOLT-NEXT: movl {{.*}}(%rip), %edi
50 # PIE-BOLT-NEXT: movl {{.*}}(%rip), %edi
51 # DISASM-NEXT: movl {{.*}}(%rip), %edi
53 test
%rdi
, foo@GOTPCREL
(%rip
)
54 # NO-RELAX-BOLT-NEXT: testq %rdi, DATA{{.*}}(%rip)
55 # BOLT-NEXT: testq $foo, %rdi
56 # PIE-BOLT-NEXT: testq %rdi, DATA{{.*}}(%rip)
57 # DISASM-NEXT: testq $0x[[#ADDR]], %rdi
59 cmpq foo@GOTPCREL
(%rip
), %rax
60 # NO-RELAX-BOLT-NEXT: cmpq DATA{{.*}}(%rip), %rax
61 # BOLT-NEXT: cmpq $foo, %rax
62 # PIE-BOLT-NEXT: cmpq DATA{{.*}}(%rip), %rax
63 # DISASM-NEXT: cmpq $0x[[#ADDR]], %rax
65 jmp
*foo@GOTPCREL
(%rip
)
66 # NO-RELAX-BOLT-NEXT: jmpq *DATA{{.*}}(%rip)
68 # PIE-BOLT-NEXT: jmp foo
69 # DISASM-NEXT: jmp 0x[[#ADDR]]
71 # DISASM: [[#ADDR]] <foo>:
75 .size _start, .-_start