bpf: gas: add field overflow checking to the BPF assembler
authorJose E. Marchesi <jose.marchesi@oracle.com>
Sun, 30 Jul 2023 19:01:03 +0000 (21:01 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Sun, 30 Jul 2023 19:08:14 +0000 (21:08 +0200)
commit0346042938539324a5052cc09023c1fe426e8b31
treea23d300951c394601cb51ceeef7719a8788b962c
parent82be476a08a2d6ee787af9a463386fab5dd85fdd
bpf: gas: add field overflow checking to the BPF assembler

This patch makes the BPF assembler to throughfully check for overflow
in immediates.  This includes relaxed instructions.

Tested in bpf-unknown-none.

gas/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

* config/tc-bpf.c (signed_overflow): Copy function from
tc-aarch64.c.
(encode_insn): Check for overflow in constant immediates.
(add_relaxed_insn): Pass relax argument to encode_insn.
(add_fixed_insn): Likewise.
* testsuite/gas/bpf/disp16-overflow.d: New file.
* testsuite/gas/bpf/disp16-overflow.s: Likewise.
* testsuite/gas/bpf/disp16-overflow.l: Likewise.
* testsuite/gas/bpf/disp32-overflow.d: Likewise.
* testsuite/gas/bpf/disp32-overflow.s: Likewise.
* testsuite/gas/bpf/disp32-overflow.l: Likewise.
* testsuite/gas/bpf/imm32-overflow.d: Likewise.
* testsuite/gas/bpf/imm32-overflow.s: Likewise.
* testsuite/gas/bpf/imm32-overflow.l: Likewise.
* testsuite/gas/bpf/offset16-overflow.d: Likewise.
* testsuite/gas/bpf/offset16-overflow.s: Likewise.
* testsuite/gas/bpf/offset16-overflow.l: Likewise.
* testsuite/gas/bpf/disp16-overflow-relax.d: Likewise.
* testsuite/gas/bpf/disp16-overflow-relax.l: Likewise.
* testsuite/gas/bpf/disp16-overflow-relax.s: Likewise.
* testsuite/gas/bpf/jump-relax-jump-be.d: New file.
* testsuite/gas/bpf/bpf.exp: Run new tests.
19 files changed:
gas/ChangeLog
gas/config/tc-bpf.c
gas/testsuite/gas/bpf/bpf.exp
gas/testsuite/gas/bpf/disp16-overflow-relax.d [new file with mode: 0644]
gas/testsuite/gas/bpf/disp16-overflow-relax.l [new file with mode: 0644]
gas/testsuite/gas/bpf/disp16-overflow-relax.s [new file with mode: 0644]
gas/testsuite/gas/bpf/disp16-overflow.d [new file with mode: 0644]
gas/testsuite/gas/bpf/disp16-overflow.l [new file with mode: 0644]
gas/testsuite/gas/bpf/disp16-overflow.s [new file with mode: 0644]
gas/testsuite/gas/bpf/disp32-overflow.d [new file with mode: 0644]
gas/testsuite/gas/bpf/disp32-overflow.l [new file with mode: 0644]
gas/testsuite/gas/bpf/disp32-overflow.s [new file with mode: 0644]
gas/testsuite/gas/bpf/imm32-overflow.d [new file with mode: 0644]
gas/testsuite/gas/bpf/imm32-overflow.l [new file with mode: 0644]
gas/testsuite/gas/bpf/imm32-overflow.s [new file with mode: 0644]
gas/testsuite/gas/bpf/jump-relax-jump-be.d [new file with mode: 0644]
gas/testsuite/gas/bpf/offset16-overflow.d [new file with mode: 0644]
gas/testsuite/gas/bpf/offset16-overflow.l [new file with mode: 0644]
gas/testsuite/gas/bpf/offset16-overflow.s [new file with mode: 0644]