1 ## Check that BOLT can correctly use relocations to symbolize instruction
2 ## operands when an instruction can have up to two relocations associated
3 ## with it. The test checks that the update happens in the function that
4 ## is not being optimized/relocated by BOLT.
6 # REQUIRES: system-linux
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 --Ttext=0x80000
10 # RUN: llvm-bolt %t.exe --relocs -o %t.bolt --funcs=foo
11 # RUN: llvm-objdump -d --print-imm-hex %t.exe \
13 # RUN: llvm-objdump -d --print-imm-hex %t.bolt \
14 # RUN: | FileCheck %s --check-prefix=CHECK-POST-BOLT
28 .type _start,@function
32 ## All four MOV instructions below are identical in the input binary, but
33 ## different from each other after BOLT.
35 ## foo value is 0x80000 pre-BOLT. Using relocations, llvm-bolt should correctly
36 ## symbolize 0x80000 instruction operand and differentiate between an immediate
37 ## constant 0x80000 and a reference to foo. When foo is relocated, BOLT should
38 ## update references even from the code that is not being updated.
43 # CHECK-POST-BOLT: <_start>:
45 movq $
0x80000, 0x80000
46 # CHECK-NEXT: movq $0x80000, 0x80000
47 # CHECK-POST-BOLT-NEXT: movq $0x80000, 0x80000
50 # CHECK-NEXT: movq $0x80000, 0x80000
51 # CHECK-POST-BOLT-NEXT: movq $0x[[#%x,ADDR:]], 0x80000
54 # CHECK-NEXT: movq $0x80000, 0x80000
55 # CHECK-POST-BOLT-NEXT: movq $0x80000, 0x[[#ADDR]]
58 # CHECK-NEXT: movq $0x80000, 0x80000
59 # CHECK-POST-BOLT-NEXT: movq $0x[[#ADDR]], 0x[[#ADDR]]
61 ## After BOLT, foo is relocated after _start.
63 # CHECK-POST-BOLT: [[#ADDR]] <foo>:
66 .size _start, .-_start