binutils Newspaper
JULY 29, 2026
pe/coff Proposed

PE/COFF: raise normal PE section limit safely

Patch to safely increase the maximum number of sections in PE/COFF files from 32767 to 65279 is reviewed positively.

This discussion confirms a positive review for a patch that safely increases the maximum number of sections allowed in normal PE/COFF files. The current limit of 32,767 sections is due to binutils using a signed 16-bit integer for symbol section numbers, whereas compilers like MSVC and Clang support a larger unsigned range up to 65,279. The patch modifies binutils to correctly handle this larger unsigned range for normal PE symbol section numbers while preserving reserved values for special symbols. A new gas test case is also added to verify this functionality.

In the Thread 3 participants
  1. Oleg Tolmatcev proposer

    Submits a patch to increase the PE/COFF section limit by correctly handling unsigned 16-bit section numbers.

    “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. ... Raise the normal PE section limit to 65279 ...”
  2. Alan Modra reviewer

    Approves the patch, stating 'This looks OK to me.'

    “This looks OK to me.”
  3. Jan Beulich reviewer

    Concurs with Alan Modra's assessment and indicates the patch will be committed soon.

    “Same here. I'll get this committed soon-ish.”

Technical Tradeoffs

  • Increasing the section limit improves compatibility with modern compilers but requires careful handling of signed/unsigned conversions to avoid breaking existing reserved values.
  • The change benefits users creating very large executables or libraries with many sections.

In Details

This patch addresses a limitation in binutils' handling of PE/COFF section counts. The COFF symbol table uses a 16-bit field for section numbers. Historically, binutils interpreted this as a signed integer, effectively limiting the maximum number of sections to 32,767. However, modern compilers like MSVC and Clang correctly use this field as an unsigned integer, supporting up to 65,279 sections. The patch modifies bfd/coffcode.h and peXXigen.c to correctly decode and encode section numbers as unsigned values within the valid range, while ensuring that reserved section numbers (undefin…

For Context
PE/COFF
Portable Executable/Common Object File Format, the file format used for executables, object code, DLLs, and system files on Windows operating systems.
section
A logical division within an executable or object file, containing related data such as code, initialized data, or uninitialized data.
symbol section number
A field in a PE/COFF symbol table entry that indicates which section the symbol belongs to.
MSVC
Microsoft Visual C++, Microsoft's integrated development environment (IDE) for C and C++ programming languages.
Clang
A C, C++, Objective-C, and Objective-C++ frontend for the LLVM compiler infrastructure.
gas
The GNU Assembler, part of the GNU Binutils package.
objdump
A standard Unix utility that displays information from object files, including symbols, sections, and disassembly.
bfd
The Binary File Descriptor library, a GNU library that provides a common interface to various object file formats.
Filed Under: binutilsPE/COFFsectionsWindowsportability