brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · ea3b893 Raw
92 lines · plain
1# In this test case, the symbol that represents the end of a table2# in .rodata is being colocated with the start of a jump table from3# another function, and BOLT moves that jump table. This should not4# cause the symbol representing the end of the table to be moved as5# well.6# Bug reported in https://github.com/llvm/llvm-project/issues/550047 8# REQUIRES: system-linux9 10# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o11# RUN: llvm-strip --strip-unneeded %t.o12# RUN: %clang %cflags -no-pie -nostartfiles -nostdlib -lc %t.o -o %t.exe -Wl,-q13 14# RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0 \15# RUN:   --reorder-blocks=reverse -jump-tables=move16 17# RUN: %t.exe.bolt 1 2 318 19  .file "jt-symbol-disambiguation.s"20  .text21 22# ----23# Func foo contains a jump table whose start is colocated with a24# symbol marking the end of a data table25# ----26  .globl foo27  .type foo, @function28foo:29  .cfi_startproc30  xor    %rax,%rax31  and    $0x3,%rdi32  leaq   .JT1(%rip), %rax33  movslq  (%rax, %rdi, 4), %rdi34  addq   %rax, %rdi35  jmpq   *%rdi36.LBB1:37  movl   $0x1,%eax38  jmp    .LBB539.LBB2:40  movl   $0x2,%eax41  jmp    .LBB542.LBB3:43  movl   $0x3,%eax44  jmp    .LBB545.LBB4:46  movl   $0x4,%eax47.LBB5:48  retq49  .cfi_endproc50  .size foo, .-foo51 52# ----53# Func _start scans a table using begin/end pointers. End pointer is colocated54# with the start of a jump table of function foo. When that jump55# table moves, end pointer in _start should not be affected.56# ----57  .globl _start58  .type _start, @function59_start:60  .cfi_startproc61  movq   (%rsp), %rdi62  callq foo63  leaq   .start_of_table(%rip), %rsi  # iterator64  leaq   .end_of_table(%rip), %rdi    # iterator end65.LBB6:66  cmpq %rsi, %rdi67  je .LBB768  movq (%rsi), %rbx69  leaq 8(%rsi), %rsi            # ++iterator70  jmp .LBB671.LBB7:72  xor   %rdi, %rdi73  callq exit@PLT74  .cfi_endproc75  .size _start, .-_start76 77# ----78# Data section79# ----80  .section .rodata,"a",@progbits81  .p2align 382.start_of_table:83  .quad 12384  .quad 45685  .quad 78986.end_of_table:87.JT1:88  .long .LBB1 - .JT189  .long .LBB2 - .JT190  .long .LBB3 - .JT191  .long .LBB4 - .JT192