1 # In this test case, we reproduce the behavior seen in gcc where the
2 # base address of a jump table is decremented by some number and ends up
3 # at the exact addess of a jump table from another function. After
4 # linking, the instruction references another jump table and that
6 # We repro here the following issue:
7 # Before assembler: Instruction operand is: jumptable - 32
8 # After linking: Instruction operand is: another_jumptable
10 # REQUIRES: system-linux, asserts
14 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
15 # RUN: llvm-strip --strip-unneeded %t.o
16 # RUN: %clang %cflags -no-pie -nostartfiles -nostdlib -lc %t.o -o %t.exe -Wl,-q
18 # RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0 \
19 # RUN: --reorder-blocks=reverse
21 # Useful when manually testing this. Currently we just check that
22 # the test does not cause BOLT to assert.
23 # COM: %t.exe.bolt 1 2
25 .file "jt-symbol-disambiguation-3.s"
29 # Func foo contains a jump table whose start is colocated with a
30 # jump table reference in another function. However, the other function
31 # does not use the first entries of it and is merely doing arithmetics
32 # to save the creation of unused first entries.
63 # Func _start scans an object with indexed access using %rax * 8 as an
64 # index. However, %rax is known to be at least one, so the compiler
65 # loads the pointer for the base address as object - 8 instead of just
69 .type _start, @function
77 # Here the compiler uses the knowledge that the first four entries
78 # of the jump table are not accessed and subtracts 32 from the base
79 # address of it, so it doesn't have to allocate four unused entries in
80 # memory. Unfortunately this can confuse BOLT since it ends up being a
81 # direct reference to JT1, after linker is done.
82 jmpq
*.JT2-32(,%rax,8)
99 .size _start, .-_start
104 .section .rodata,"a",@progbits