binutils Newspaper
JULY 29, 2026
pe/coff Proposed

PE/COFF: raise normal PE section limit safely

Increase the maximum number of sections in PE/COFF objects from 32767 to 65279 by using unsigned integers for section numbers.

This patch addresses an limitation in the PE/COFF format where the number of sections in an object file was capped at 32767 due to signed 16-bit handling of section numbers. The proposal raises this limit to 65279 by properly decoding and encoding section numbers as unsigned values, while preserving special reserved values. It also enhances error handling by rejecting invalid reserved section numbers during input reading and includes new tests for gas and binutils to ensure the changes function correctly.

In the Thread 1 participant
  1. Oleg Tolmatcev <oleg.tolmatcev@gmail.com> proposer

    Proposes to increase the normal PE section limit from 32767 to 65279 by using unsigned integers for section numbers, while maintaining correct handling of special section values and improving error checking.

    “PE/COFF stores symbol section numbers in a 16-bit field. Binutils used signed 16-bit handling there, which limited normal PE objects to 32767 sections even though MSVC and Clang already accept a larger unsigned range.”

In Details

This patch revises the PE/COFF object file parsing and writing logic within binutils to support more than 32767 sections. Previously, a signed 16-bit field for symbol section numbers imposed this limit. The change correctly uses unsigned values for normal section numbers up to 65279, while explicitly mapping the reserved section numbers (Undefined, Absolute, Debug) to ensure compatibility. It also adds input validation to catch malformed section numbers earlier and includes test cases in gas and binutils.

For Context
PE/COFF
Portable Executable/Common Object File Format, the file format used for executables, object code, and DLLs in 32-bit and 64-bit versions of Windows operating systems. It is based on the COFF format.
section number
In PE/COFF files, a number within a symbol's entry that indicates which section of the object file the symbol belongs to. Special values are reserved for symbols not associated with a specific section.
binutils
A collection of binary tools for GNU systems, including assemblers, linkers, and utilities for manipulating object files.
gas
The GNU Assembler, part of the GNU Binutils package. It translates assembly language code into machine code.
objdump
A utility from GNU Binutils that displays information from object files, including section contents and symbol tables.
Filed Under: binutilspe/cofflinkerobject-file-format