binutils Newspaper
OCTOBER 6, 2026
bfd — Proposed

bfd: pe: Introduce COFF_WITH_pe32plus define

Define COFF_WITH_pe32plus for PE32+ formats to simplify conditional logic.

This patch introduces a new preprocessor macro, COFF_WITH_pe32plus, to consolidate checks for PE32+ (64-bit) formats within bfd/peXXigen.c. This aims to replace error-prone, long lists of specific format defines with a single, clearer indicator, making the code more maintainable and reducing the likelihood of errors when handling PE32/PE32+ differences.

In Details

This patch refactors bfd/peXXigen.c by introducing COFF_WITH_pe32plus. Previously, multiple COFF_WITH_pe* defines were used to distinguish PE32+ targets. This new macro simplifies conditional logic that differentiates between PE32 and PE32+ formats, making code that handles these differences more readable and less prone to copy-paste errors. It's a code hygiene improvement.

For Context
PE32+
A 64-bit version of the Portable Executable (PE) file format, commonly used for executables on Windows.
preprocessor macro
A directive in C/C++ code that the preprocessor expands before compilation, often used for conditional compilation or defining constants.
conditional logic
Code that executes different paths based on whether certain conditions are true or false, often implemented using #if, #ifdef, etc.
Filed Under: bfdperefactoringmaintainability