1 # In this test case, we reproduce the behavior seen in gcc where the
2 # base address of a data object is decremented by some number and lands
3 # inside a jump table from another function.
5 # REQUIRES: system-linux
7 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
8 # RUN: llvm-strip --strip-unneeded %t.o
9 # RUN: %clang %cflags -no-pie -nostartfiles -nostdlib -lc %t.o -o %t.exe -Wl,-q
11 # RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0 \
12 # RUN: --reorder-blocks=reverse -jump-tables=move
14 # RUN: %t.exe.bolt 1 2 3
16 .file "jt-symbol-disambiguation-2.s"
20 # Func foo contains a jump table whose start is colocated with a
21 # symbol marking the end of a data table
30 movslq
(%rax
, %rdi
, 4), %rdi
50 # Func _start scans an object with indexed access using %rax * 8 as an
51 # index. However, %rax is known to be at least one, so the compiler
52 # loads the pointer for the base address as object - 8 instead of just
56 .type _start, @function
62 leaq
.object-8(%rip), %rsi # indexed access base address
63 movq $
1, %rax
# start index
67 addq
(%rsi
,%rax
,8), %rbx
68 incq
%rax
# ++iterator
71 cmpq $
1368, %rbx
# check .object contents integrity
83 .size _start, .-_start
88 .section .rodata,"a",@progbits
100 .asciz "RUNTIME ASSERTION FAILURE: references in test binary are corrupt after BOLT"