aboutsummaryrefslogtreecommitdiff
path: root/gas/doc
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2023-08-17 09:38:37 +0200
committerJose E. Marchesi <jose.marchesi@oracle.com>2023-08-17 09:41:43 +0200
commit5be1b787276d2adbe85ae7febc709ca517b62f08 (patch)
tree78eee9ce0af69c9ac2d98af1204dd771b46893f6 /gas/doc
parent646657284f6b62a71a6869826e951b3def4d73a6 (diff)
downloadgdb-5be1b787276d2adbe85ae7febc709ca517b62f08.zip
gdb-5be1b787276d2adbe85ae7febc709ca517b62f08.tar.gz
gdb-5be1b787276d2adbe85ae7febc709ca517b62f08.tar.bz2
bpf: gas: consolidate handling of immediate overflows
This commit changes the BPF GAS port in order to handle immediate overflows the same way than the clang BPF assembler: - For an immediate field of N bits, any written number (positive or negative) whose two's complement encoding fit in N its is accepted. This means that -2 is the same than 0xffffffe. It is up to the instructions to decide how to interpret the encoded value. - Immediate fields in jump instructions are no longer relaxed. Relaxing to jump instructions with wider range is only performed when expressions are involved. - The manual is updated to document this, and testsuite adapted accordingly. Tested in x86_64-linux-gnu host, bpf-unknown-none target. gas/ChangeLog: 2023-08-17 Jose E. Marchesi <jose.marchesi@oracle.com> * config/tc-bpf.c (check_immediate_overflow): New function. (encode_insn): Use check_immediate_overflow. (md_assemble): Do not relax instructions with constant disp16 fields. * doc/c-bpf.texi (BPF Instructions): Add note about how numerical literal values are interpreted for instruction immediate operands. * testsuite/gas/bpf/disp16-overflow.s: Adapt accordingly. * testsuite/gas/bpf/jump-relax-jump.s: Likewise. * testsuite/gas/bpf/jump-relax-jump.d: Likewise. * testsuite/gas/bpf/jump-relax-jump-be.d: Likewise. * testsuite/gas/bpf/jump-relax-ja.s: Likewise. * testsuite/gas/bpf/jump-relax-ja.d: Likewise. * testsuite/gas/bpf/jump-relax-ja-be.d: Likewise. * testsuite/gas/bpf/disp16-overflow-relax.l: Likewise. * testsuite/gas/bpf/imm32-overflow.s: Likewise. * testsuite/gas/bpf/disp32-overflow.s: Likewise. * testsuite/gas/bpf/disp16-overflow.l: Likewise. * testsuite/gas/bpf/disp32-overflow.l: Likewise. * testsuite/gas/bpf/imm32-overflow.l: Likewise. * testsuite/gas/bpf/offset16-overflow.l: Likewise.
Diffstat (limited to 'gas/doc')
-rw-r--r--gas/doc/c-bpf.texi8
1 files changed, 8 insertions, 0 deletions
diff --git a/gas/doc/c-bpf.texi b/gas/doc/c-bpf.texi
index 6b43c77..75372de 100644
--- a/gas/doc/c-bpf.texi
+++ b/gas/doc/c-bpf.texi
@@ -172,6 +172,14 @@ Signed 32-bit immediate.
Signed 64-bit immediate.
@end table
+@noindent
+Note that the assembler allows to express the value for an immediate
+using any numerical literal whose two's complement encoding fits in
+the immediate field. For example, @code{-2}, @code{0xfffffffe} and
+@code{4294967294} all denote the same encoded 32-bit immediate, whose
+value may be then interpreted by different instructions as either as a
+negative or a positive number.
+
@subsection Arithmetic instructions
The destination register in these instructions act like an