binutils Newspaper
NOVEMBER 30, 2026
ld/pep — Proposed

ld/pep: remove unused support_old_code variable

Removes an unused variable `support_old_code` from ld/pep, resolving compiler warnings.

This patch removes the support_old_code variable from the PE object file format handling in the linker (ld/pep). This variable was inherited from pe.em but is only used for ARM PE targets, which pep.em does not handle. Consequently, it triggers an unused variable warning when building with Clang. The patch removes the variable declaration and its handling while retaining the --support-old-code option’s acceptance for compatibility. This cleans up the codebase and resolves compiler warnings.

In the Thread 1 participant
  1. Simon Marchi <simon.marchi@efficios.com> proposer

    Submits a patch to remove an unused `support_old_code` variable from ld/pep, resolving Clang warnings.

    “Building ld with a recent clang fails with: ei386pep.c:131:12: error: variable 'support_old_code' set but not used [-Werror,-Wunused-but-set-global] The same happens for the other emulations generated from pep.em.”

In Details

This patch targets the PE (Portable Executable) template file ld/emultempl/pep.em, used for generating linker configurations for PE targets. The variable support_old_code was copied from pe.em but is only relevant for ARM PE targets, not the x86-focused targets typically handled by pep.em. Its presence leads to [-Wunused-but-set-global] warnings from Clang. The patch removes the variable and its associated option handler, cleaning up the unused code.

For Context
PE
Portable Executable, the file format used for executables, object code, and DLLs on 32-bit and 64-bit versions of Windows. It is also used by the linker for some embedded targets.
ld/pep
The linker configuration template for PE (Portable Executable) object files, likely an extension or variant of the standard PE handling in binutils.
ARM PE targets
Targets that use the Portable Executable (PE) file format, commonly associated with Windows, but also used for certain embedded systems, and specifically here, for ARM architectures.
linker template
A generic file used by the linker to generate specific configurations for different target architectures or operating systems. Changes to the template are propagated to all generated configurations.
Filed Under: binutilsldlinkerpepcompiler warnings