binutils Newspaper
OCTOBER 6, 2026
bpf — Proposed

BPF gas: Diagnose instructions above selected ISA spec

BPF gas now provides clearer diagnostics for instructions requiring a higher ISA spec than selected.

This patch enhances the BPF assembler’s error reporting. Previously, using an instruction not available in the selected ISA spec resulted in misleading errors, such as ‘unrecognized instruction’ or ‘expected white space’. The updated md_assemble function now attempts to match templates above the current ISA spec for diagnostic purposes. If a match is found, it reports the specific ISA spec required (e.g., ‘requires ISA spec v4 or later’), providing much clearer feedback to the user.

In the Thread 2 participants
  1. Jose E. Marchesi reviewer

    Approves the patch for the master branch, acknowledging the improved diagnostics for ISA spec mismatches.

    “OK for master. Thanks!”
  2. Vineet Gupta proposer

    Introduces improved diagnostics for BPF instructions that require an ISA spec higher than the one currently selected.

    “Attempt those templates too, but only for the diagnostic: if one matches the whole statement, remember it and keep scanning, since a template within the ISA spec may still match.”

Technical Tradeoffs

  • Provides much clearer error messages for ISA version mismatches.
  • Increases the complexity of the `md_assemble` function.
  • Ensures that valid instructions within the selected ISA are still correctly assembled.

In Details

This patch refactors the BPF assembler's md_assemble function to improve diagnostics when an instruction requires a higher ISA specification than currently selected. Previously, such attempts resulted in generic errors like 'unrecognized instruction'. The change now allows md_assemble to temporarily consider templates from future ISA specs. If an instruction matches such a template, the assembler remembers it and continues parsing. Only if no valid template within the current ISA spec is found does it emit a specific error message indicating the required ISA version (e.g., 'requires ISA s…

For Context
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.
ISA spec
Instruction Set Architecture specification. Refers to a particular version or feature set of the BPF instruction set that the assembler is targeting.
md_assemble
A function within the gas assembler responsible for parsing and assembling machine instructions based on the target architecture's specification.
diagnostic
An error or warning message produced by a compiler or assembler to inform the user about issues in the source code.

Part of a Series

Filed Under: BPFgasassemblerdiagnosticsISA