binutils Newspaper
NOVEMBER 30, 2026
gas — Proposed

gas: bpf: accept r11, the stack argument register

The `gas` assembler now accepts `r11` as a register for BPF stack arguments.

This patch modifies the GNU Assembler (gas) for BPF to accept r11 as a valid register name. The kernel has supported r11 for passing function arguments beyond the first five since version 7.2, and clang also emits code using it. Previously, gas only recognized registers r0 through r10. This change enables gas to correctly assemble instructions that use r11 for stack arguments, ensuring compatibility with newer kernel and compiler features.

In the Thread 2 participants
  1. Vineet Gupta proposer

    Submitted a patch to allow `gas` to recognize `r11` for BPF stack arguments, aligning with kernel and `clang` support.

    “BPF functions with more than five arguments pass the rest on the stack, addressed through r11: the kernel has accepted that since 7.2 [1], and clang emits it [2]. No new instructions are involved, only 64-bit loads and stores with r11 as the base register:”
  2. Jose E. Marchesi reviewer

    Reviewed the patch and approved it for the master branch.

    “Thanks for the patch. OK for master!”

Technical Tradeoffs

  • Enables `gas` to support newer BPF calling conventions.
  • Minimal code change, primarily an update to register definitions and documentation.

In Details

This patch updates gas/config/tc-bpf.c and gas/doc/c-bpf.texi to include r11 in the list of recognized BPF registers for gas. This is necessary because the Linux kernel (since 7.2) and clang utilize r11 to handle function arguments that exceed the standard register set, passing them via the stack. The change ensures that gas can correctly parse and assemble BPF code that uses r11 for these stack-based arguments, including adding relevant test cases.

For Context
gas
The GNU Assembler, part of the GNU Binutils project, responsible for converting assembly language code into machine code.
BPF
Berkeley Packet Filter, a technology that allows programs to be run in the Linux kernel without altering kernel source code. It's often used for network packet filtering and more general in-kernel computation.
r11
A register used in the BPF instruction set. In this context, it's used for passing arguments beyond the first five via the stack.
stack argument
A function argument passed via the call stack, typically used when the number of arguments exceeds the number of available registers.

Part of a Series

Filed Under: gasBPFassemblerkernel