binutils Newspaper
OCTOBER 6, 2026
gas — Proposed

BPF gas: Test `gotol` in compound conditional jumps

BPF gas now includes a test case for `gotol` within compound conditional jumps, ensuring correct parsing and assembly.

This patch adds a new test case to the BPF assembler’s test suite to specifically cover the gotol instruction when used within compound conditional jumps. The existing fix for gotol only addressed standalone instances; compound conditional jumps embed a goto%w%d16 form, making them susceptible to misassembly without this dedicated test. The new test verifies that the assembler correctly handles these scenarios, preventing silent failures and incorrect relocations.

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

    Approves the patch for the master branch, acknowledging its importance in testing the `gotol` instruction within compound conditional jumps.

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

    Introduces a test for the `gotol` instruction within compound conditional jumps in the BPF assembler.

    “Add a test for the compound forms, so the reordering alternative does not look equivalent to %t. Verified that it fails when %t is replaced by the reordering: no diagnostic, and each of its three lines silently encoded as a conditional jump with a relocation against `l'.”

Technical Tradeoffs

  • Ensures correct assembly of `gotol` within compound conditional jumps.
  • Adds test coverage for a previously untested scenario.
  • Validates the effectiveness of the `%t` specifier in distinguishing similar mnemonics.

In Details

This patch introduces a new test suite (jump-gotol-cond-pseudoc.*) for the BPF gas assembler to specifically exercise the gotol instruction within compound conditional jumps. The context is that a previous fix only addressed standalone gotol by reordering opcodes, but compound conditional jumps use a different goto form. This test verifies that the %t token boundary specifier correctly distinguishes gotol from goto in these complex cases, preventing silent misassemblies and incorrect relocations that would occur if opcode reordering were the sole fix.

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.
gotol
A BPF assembler instruction, likely a variant of 'goto' with a specific operand format or target type.
compound conditional jump
A control flow instruction in assembly that combines a conditional check with a jump, potentially involving multiple conditions or complex operand processing.
Relocation
A process performed by the linker to adjust memory addresses in machine code after assembly, typically to resolve references to symbols or labels defined elsewhere.

Part of a Series

Filed Under: BPFgasassemblertestingcontrol flow