68 lines · plain
1## Check that BOLT can correctly use relocations to symbolize instruction2## operands when an instruction can have up to two relocations associated3## with it. The test checks that the update happens in the function that4## is not being optimized/relocated by BOLT.5 6# REQUIRES: system-linux7 8# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o9# RUN: ld.lld %t.o -o %t.exe -q --image-base=0x80000 --Ttext=0x8000010# RUN: llvm-bolt %t.exe --relocs -o %t.bolt --funcs=foo11# RUN: llvm-objdump -d --print-imm-hex %t.exe \12# RUN: | FileCheck %s13# RUN: llvm-objdump -d --print-imm-hex %t.bolt \14# RUN: | FileCheck %s --check-prefix=CHECK-POST-BOLT15 16 .text17 .globl foo18 .type foo,@function19foo:20 .cfi_startproc21 ret22 .cfi_endproc23 .size foo, .-foo24 25 26 .text27 .globl _start28 .type _start,@function29_start:30 .cfi_startproc31 32## All four MOV instructions below are identical in the input binary, but33## different from each other after BOLT.34##35## foo value is 0x80000 pre-BOLT. Using relocations, llvm-bolt should correctly36## symbolize 0x80000 instruction operand and differentiate between an immediate37## constant 0x80000 and a reference to foo. When foo is relocated, BOLT should38## 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, 0x8000046# CHECK-NEXT: movq $0x80000, 0x8000047# CHECK-POST-BOLT-NEXT: movq $0x80000, 0x8000048 49 movq $foo, 0x8000050# CHECK-NEXT: movq $0x80000, 0x8000051# CHECK-POST-BOLT-NEXT: movq $0x[[#%x,ADDR:]], 0x8000052 53 movq $0x80000, foo54# CHECK-NEXT: movq $0x80000, 0x8000055# CHECK-POST-BOLT-NEXT: movq $0x80000, 0x[[#ADDR]]56 57 movq $foo, foo58# CHECK-NEXT: movq $0x80000, 0x8000059# 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 retq66 .size _start, .-_start67 .cfi_endproc68