binutils Newspaper
JULY 29, 2026
gas Proposed

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

Adds support for .pushsection/.popsection to the COFF object file format in GAS.

This patch adds support for the .pushsection and .popsection pseudo-operations to the COFF object file format in the GNU assembler (GAS). These directives are crucial for building current Linux kernels, which normally use ELF. When targeting Windows/ReactOS drivers (COFF), these operands were previously unsupported. The implementation was copied from the ELF backend, enabling Linux kernel compilation as a COFF object.

In Details

This patch extends the GNU Assembler's (GAS) COFF backend to support section management directives .pushsection and .popsection. These are essential for building Linux kernel components for Windows/ReactOS (COFF/PE targets), allowing developers to maintain section state across nested code/data segments, similar to the existing ELF support. The implementation is a direct port from obj-elf.c to obj-coff.c.

For Context
.pushsection
An assembler pseudo-operation that saves the current section description and then starts a new section.
.popsection
An assembler pseudo-operation that restores the section description that was previously saved by a corresponding .pushsection.
COFF
Common Object File Format, a file format for executable and object code, primarily used on Windows systems.
ELF
Executable and Linkable Format, a standard file format for executable, object code, shared libraries, and core dumps, commonly used on Unix-like systems.
GNU assembler (GAS)
The assembler program distributed as part of the GNU Binutils package. It supports multiple input and output formats.
Filed Under: binutilsgasassemblercoffsection