PE/COFF: raise normal PE section limit safely

Project / Subsystem

binutils / pe/coff

Date

2026-07-05

Proposer

Oleg Tolmatcev <oleg.tolmatcev@gmail.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Increases the maximum section count, potentially improving compatibility with tools that generate large numbers of sections.

All attributes

project
binutils
subsystem
pe/coff
patch_id
discussion_id
20260705220703.1725-2-oleg.tolmatcev@gmail.com
source_type
public_inbox
title
PE/COFF: raise normal PE section limit safely
headline
PE/COFF: raise normal PE section limit safely
tldr
Increase the maximum number of sections in PE/COFF objects from 32767 to 65279 by using unsigned integers for section numbers.
proposer
Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Increases the maximum section count, potentially improving compatibility with tools that generate large numbers of sections.
series_id
series_role
cover
series_parts
[]
tags
  • binutils
  • pe/coff
  • linker
  • object-file-format
bugzilla_url
date
2026-07-05T00:00:00.000Z

PE/COFF: raise normal PE section limit safely

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.