brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 12fe691 Raw
69 lines · plain
1## This reproduces a bug with jump table identification where jump table has2## entries pointing to code in function and its cold fragment.3 4# REQUIRES: system-linux5 6# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o7# RUN: llvm-strip --strip-unneeded %t.o8# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q9# RUN: llvm-bolt %t.exe -o %t.out --lite=0 -v=1 --print-cfg --print-only=main \10# RUN:   2>&1 | FileCheck %s11 12# CHECK-NOT: unclaimed PC-relative relocations left in data13# CHECK: BOLT-INFO: marking main.cold.1 as a fragment of main14  .text15  .globl main16  .type main, %function17  .p2align 218main:19LBB0:20  andl $0xf, %ecx21  cmpb $0x4, %cl22  ## exit through abort in main.cold.1, registers cold fragment the regular way23  ja main.cold.124 25## jump table dispatch, jumping to label indexed by val in %ecx26LBB1:27  leaq JUMP_TABLE(%rip), %r828  movzbl %cl, %ecx29  movslq (%r8,%rcx,4), %rax30  addq %rax, %r831  jmpq *%r832 33LBB2:34  xorq %rax, %rax35LBB3:36  addq $0x8, %rsp37  ret38.size main, .-main39 40## Insert padding between functions, so that the next instruction cannot be41## treated as __builtin_unreachable destination for the jump table.42  .quad 043 44  .globl main.cold.145  .type main.cold.1, %function46  .p2align 247main.cold.1:48LBB4:49  callq abort50.size main.cold.1, .-main.cold.151 52  .rodata53## jmp table, entries must be R_X86_64_PC32 relocs54  .globl JUMP_TABLE55JUMP_TABLE:56  .long LBB2-JUMP_TABLE57  .long LBB3-JUMP_TABLE58  .long LBB4-JUMP_TABLE59  .long LBB3-JUMP_TABLE60 61## Verify that the entry corresponding to the cold fragment was added to62## the jump table.63 64# CHECK:      PIC Jump table65# CHECK-NEXT: 0x{{.*}} :66# CHECK-NEXT: 0x{{.*}} :67# CHECK-NEXT: 0x{{.*}} : main.cold.168# CHECK-NEXT: 0x{{.*}} :69