binutils Newspaper
OCTOBER 6, 2026
binutils — Proposed

BPF assembler: Fix `gotol' and `goto' mnemonic parsing

Corrects BPF assembler to handle `gotol' and `goto' mnemonics with flexible spacing and signed offsets.

Vineet Gupta and Jose E. Marchesi discuss the nuances of parsing BPF assembler instructions, specifically the goto and gotol mnemonics. The conversation clarifies that the assembler must support flexible spacing around operands and signs, and that whitespace handling by gas can interfere with this. They explore solutions involving reordering opcode tables to correctly assemble instructions like gotol and goto with signed offsets, addressing issues highlighted in PR 34558.

In the Thread 2 participants
  1. Vineet Gupta <vineet.gupta@linux.dev> proposer

    Explains that the `%W` template approach is insufficient due to whitespace handling and flexible operand spacing.

    “Yet another reason the %w approach won't work. Anyways.... I don't understand that implication.”
  2. Jose E. Marchesi reviewer

    Proposes reordering the opcodes table as a fix for existing issues with `goto` and `gotol` mnemonics.

    “In any case, wouldn't simply reordering the opcodes table like below fix the existing broken issues without having to add special casing to the generic template-based parser? Something like this passes the new test:”

Technical Tradeoffs

  • Reordering the opcode table is a less invasive change than modifying the core parsing logic.
  • Ensures compatibility with existing BPF assembly syntax, including flexible spacing.

In Details

This exchange delves into the intricacies of the BPF assembler's instruction parsing, specifically the goto and gotol mnemonics. The problem stems from how gas handles whitespace and parses operands, which affects the flexibility of writing BPF assembly. The discussion revolves around fixing PR 34558 by potentially reordering the opcode table to ensure correct assembly of these instructions with signed offsets and varying spacing.

For Context
BPF
Berkeley Packet Filter. A technology that allows for safe and efficient execution of custom code within the Linux kernel, often used for networking and security tasks.
PR 34558
Problem Report number 34558, referring to a specific bug or issue filed in the binutils bug tracking system.
mnemonic
A symbolic name that represents a machine language instruction, used in assembly language.
gas
The GNU Assembler, part of the GNU toolchain, used to translate assembly language code into machine code.

Part of a Series

Filed Under: bpfassemblerparsinggotolinker