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. 5 6# REQUIRES: system-linux 7 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 \ 12# RUN: | FileCheck %s 13# RUN: llvm-objdump -d --print-imm-hex %t.bolt \ 14# RUN: | FileCheck %s --check-prefix=CHECK-POST-BOLT 15 16 .text 17 .globl foo 18 .type foo,@function 19foo: 20 .cfi_startproc 21 ret 22 .cfi_endproc 23 .size foo, .-foo 24 25 26 .text 27 .globl _start 28 .type _start,@function 29_start: 30 .cfi_startproc 31 32## All four MOV instructions below are identical in the input binary, but 33## different from each other after BOLT. 34## 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. 39 40# CHECK: 80000 <foo>: 41 42# CHECK: <_start>: 43# CHECK-POST-BOLT: <_start>: 44 45 movq $0x80000, 0x80000 46# CHECK-NEXT: movq $0x80000, 0x80000 47# CHECK-POST-BOLT-NEXT: movq $0x80000, 0x80000 48 49 movq $foo, 0x80000 50# CHECK-NEXT: movq $0x80000, 0x80000 51# CHECK-POST-BOLT-NEXT: movq $0x[[#%x,ADDR:]], 0x80000 52 53 movq $0x80000, foo 54# CHECK-NEXT: movq $0x80000, 0x80000 55# CHECK-POST-BOLT-NEXT: movq $0x80000, 0x[[#ADDR]] 56 57 movq $foo, foo 58# CHECK-NEXT: movq $0x80000, 0x80000 59# CHECK-POST-BOLT-NEXT: movq $0x[[#ADDR]], 0x[[#ADDR]] 60 61## After BOLT, foo is relocated after _start. 62 63# CHECK-POST-BOLT: [[#ADDR]] <foo>: 64 65 retq 66 .size _start, .-_start 67 .cfi_endproc 68