llvm-project/bolt/test/AArch64/data-at-0-offset.c
Denis Revunov 0b7e8baf83 [BOLT][AArch64] Handle data at the beginning of a function when disassembling and building CFG.
This patch adds getFirstInstructionOffset method for BinaryFunction
which is used to properly handle cases where data is at zero offset in
a function. The main change is that we add basic block at first
instruction offset when disassembling, which prevents assertion
failures in buildCFG.

Reviewed By: yota9, rafauler

Differential Revision: https://reviews.llvm.org/D127111
2022-06-09 15:26:32 -07:00

18 lines
414 B
C

// RUN: %clang %cflags -O2 -fPIE -Wl,-q -pie %s -o %t.exe
// RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
// CHECK-NOT: BOLT-WARNING: unable to disassemble instruction at offset
void extra_space() {
asm volatile(".rept 256\n"
" .byte 0xff\n"
".endr\n");
return;
}
int main(int argc, char **argv) {
void (*fn)(void);
fn = extra_space + 256;
fn();
return 0;
}