BPF gas: Fix `gotol` misassembly with signed offset
BPF gas `gotol` instruction now correctly assembles signed offsets, resolving libbpf load-time failures.
This patch series addresses an issue in the BPF assembler (gas) where the gotol instruction was silently misassembled when given a signed offset. This led to errors during libbpf loading. The series introduces a more robust parsing mechanism using the %t token boundary specifier to correctly distinguish gotol from goto, especially in contexts with flexible spacing. It also includes fixes for related issues like testing gotol in compound conditional jumps and improving ISA spec diagnostics.
- reviewer
Acknowledges the series, approving patches and providing feedback on specific issues like the `gotol` test coverage.
“OK for master. Thanks!”
- proposer
Submits a series of patches to fix the misassembly of BPF's `gotol` instruction with signed offsets.
“In the pseudo-C dialect `gotol +1' is silently assembled as `goto l+1' leading to libbpf load time failures.”
Technical Tradeoffs
- Fixes critical bugs leading to runtime failures in libbpf.
- Improves assembler robustness and accuracy.
- Introduces a new parsing specifier (`%t`) for stricter tokenization.
In Details
This is the cover letter for a series of patches fixing BPF gotol instruction assembly issues in GNU gas. The core problem is that gotol +1 is misassembled as goto l+1 due to ambiguous parsing, causing libbpf load failures. Patch 1 enables a never-run test suite (spacing-pseudoc) that reveals this and other spacing issues. Patch 2 directly fixes the gotol misassembly using the %t token boundary specifier, moving away from previous attempts like specific parser workarounds or opcode reordering. Patch 3 generalizes the %t usage to 65 other mnemonics for consistency and future-proo…
- BPF
- Berkeley Packet Filter, a technology that allows sandboxed programs to safely execute code in the Linux kernel, often used for networking and tracing.
- gas
- The GNU Assembler, part of the GNU Binutils package, responsible for converting assembly language code into machine code.
- gotol
- A BPF assembler instruction, likely a variant of 'goto' with a specific operand format or target type.
- libbpf
- A library providing helper functions for loading, compiling, and interacting with BPF programs in the Linux kernel.
- pseudo-C dialect
- A specific assembly syntax or dialect used for BPF, which resembles C language constructs for clarity and testing purposes.
- %t specifier
- A format specifier in the gas opcode table that signifies a token boundary, ensuring that the preceding text is treated as a complete mnemonic and not extended by subsequent characters.