binutils Newspaper
JULY 29, 2026
gas Proposed Sentiment 8 / 10

gas: support for .pushsection and .popsection pseudo ops for coff

Adds support for .pushsection and .popsection directives to the COFF object file format in the gas assembler.

This patch adds support for the .pushsection and .popsection pseudo-operations to the GNU Assembler (gas) when generating COFF object files. These directives are heavily used in current Linux kernels compiled as ELF, and this change enables the Linux kernel to be compiled as a COFF object for Windows/ReactOS drivers. The implementation was copied from the ELF object code, and includes a new test case.

In the Thread 2 participants
  1. Maciej W. Rozycki <macro@orcam.me.uk> reviewer

    Acknowledged the patch and requested a reword of the commit message and description to use the imperative mood, as is standard for Git commit messages.

    “Please reword using the imperative mood both for the change heading and the description.”
  2. Johannes Khoshnazar-Thoma <johannes@johannesthoma.com> proposer

    Submits a patch to add .pushsection and .popsection support to gas for the COFF format, enabling compilation of Linux kernel drivers for Windows/ReactOS.

    “Current Linux kernels make heavy use of the .pushsection and .popsection pseudo ops. Normally, the Linux kernel is built as an ELF object, where the assembler supports those pseudo ops. When compiling the Linux kernel as a Windows/ReactOS driver however, it must be compiled as a COFF object, since the Windows/ReactOS kernel does not know how to load ELF binaries. In order to be able to compile t…”

Technical Tradeoffs

  • Reusing code from ELF for COFF simplifies development but may not perfectly map all semantics if underlying format differences are significant.
  • Adding support for these directives enables cross-platform compilation scenarios, increasing flexibility for kernel developers targeting Windows.

In Details

This patch extends the GNU Assembler's (gas) support for section manipulation to the COFF object file format. It backports the .pushsection and .popsection directives, previously only available for ELF, to COFF. This is crucial for building components like the Linux kernel drivers that rely on these directives when targeting Windows/ReactOS environments (PE32/COFF). The implementation leverages existing ELF logic.

For Context
gas
The GNU Assembler, a component of the GNU Binutils package that translates assembly language code into machine code.
COFF
Common Object File Format. A standard binary file format for executables, object code, and libraries, primarily used on Windows systems.
ELF
Executable and Linkable Format. A standard binary file format commonly used on Unix-like operating systems for executables, object code, shared libraries, and core dumps.
.pushsection / .popsection
Assembler directives that allow temporarily saving the current section and switching to a new one, with .popsection restoring the previously active section. Used for managing code/data placement.
pseudo-ops
Assembler instructions that do not generate machine code directly but control the assembly process, such as defining sections or symbols.
Filed Under: assemblerbinutilsgasCOFFsection management