binutils Newspaper
OCTOBER 6, 2026
bpf — Proposed

bpf: fix gotol with a signed offset, and run the spacing test

Fixes BPF assembler misassembly of `gotol` with signed offsets and enables a related test case.

This patch series addresses two issues in the BPF backend of the GNU Assembler (gas). First, it fixes a bug where gotol + imm was misassembled as goto label + imm, leading to runtime failures in libbpf. Second, it enables a previously disabled test case, spacing-pseudoc.s/.d, which is relevant to testing jump instructions. The author notes that a proposed solution using %W for whitespace did not work due to how gas parses operands.

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

    Submits patches to fix BPF assembler misassembly of `gotol` with signed offsets and to enable a related test case, noting issues with previous suggestions.

    “Ping ! On 8/25/26 3:11 AM, Vineet Gupta wrote: > In the pseudo-C dialect `gotol +1' is silently assembled as `goto l+1' > leading to libbpf load time failures. LLVM obviously supports this so gas > needs fixing. > > Ran into this when trying to enable certain selftests which are > currently clang built only while GCC can build them fine. Moreover those > not run tests are declared passing too […”

In Details

This patch series updates the GNU Assembler's BPF backend. It corrects how gotol instructions with signed immediate offsets are parsed and assembled, resolving an incompatibility with libbpf's handling of these instructions. Additionally, it ensures a relevant test case (spacing-pseudoc.s/.d) is executed, which previously existed but was not run. The fix for gotol addresses a subtle interaction between operand parsing and assembler directives, particularly when whitespace is involved around signed immediates.

For Context
BPF
Berkeley Packet Filter. A technology that allows sandboxed programs to run efficiently in the Linux kernel for network packet filtering, tracing, and other tasks.
gas
The GNU Assembler, part of the GNU Binutils project. It translates assembly language code into machine code.
libbpf
A userspace library that helps load and interact with BPF programs running in the Linux kernel.
PIE
Position-Independent Executable. An executable file that can be loaded at any address in memory without modification. This is achieved through special relocation entries and is crucial for security and flexibility.
ET_DYN
Executable ELF file type. Indicates a dynamically linked executable or a shared object. PIE executables are of this type.
UEFI
Unified Extensible Firmware Interface. A specification that defines the software interface between an operating system and platform firmware. UEFI applications are typically loaded and run by the UEFI firmware.
R_RISCV_RELATIVE
A RISC-V specific relocation type used for position-independent code, where the relocation value is determined by adding the image's base address to the symbol's offset.
elf32lriscv-defs.sh
A shell script within Binutils that defines linker emulation parameters specific to the 32-bit little-endian RISC-V architecture.
ld
The GNU linker, responsible for combining object files and libraries into an executable or library.
gotol
A BPF assembly instruction that likely represents a jump to a label with an offset.
Filed Under: binutilsgasbpfassemblerregression-test