Files
clang-p2996/llvm/test/MC/BPF/expr-offset.s
Eduard Zingerman f22442553b [BPF] Check jump and memory offsets to avoid truncation
The following assembly code should issue two errors specifying that
both jump and load offsets are out of range:

  if r1 > r2 goto +100500
  r1 = *(u64 *)(r1 - 100500)

This commit updates BPFAsmParser to check that:
- offset specified for jump is either identifier (label) or a 16-bit
  signed constant;
- offset specified for memory operations is a signed 16-bit constant.

(Which matches expectations in the BPFELFObjectWriter and
 BPFMCCodeEmitter).

Differential Revision: https://reviews.llvm.org/D158425
2023-09-23 19:39:24 +03:00

13 lines
280 B
ArmAsm

# RUN: llvm-mc -triple bpfel -filetype=obj < %s \
# RUN: | llvm-objdump --no-print-imm-hex --no-show-raw-insn -d - \
# RUN: | FileCheck %s
.equ foo, -1
if r1 > r2 goto foo + 2
exit
exit
# CHECK: if r1 > r2 goto +1
# CHECK: exit
# CHECK: exit