binutils Newspaper
NOVEMBER 30, 2026
ld/ppc32elf — Proposed

ld/ppc32elf: only define old_got for non-VxWorks targets

Removes unused 'old_got' variable from the ppc32elf linker template for VxWorks targets to fix compiler warnings.

This patch addresses a compiler warning about an unused global variable, ‘old_got’, on VxWorks targets. The variable and its associated option handling are only relevant for non-VxWorks targets. The change moves the definition and option parsing of ‘old_got’ inside the existing conditional that checks for non-VxWorks builds, resolving the warning and cleaning up the code.

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

    Submits a patch to conditionally define the 'old_got' variable and its handling only for non-VxWorks targets in the ppc32elf linker, as it is unused and causes compiler warnings on VxWorks.

    “Building ld with a recent clang fails with: eelf32ppcvxworks.c:68:12: error: variable 'old_got' set but not used [-Werror,-Wunused-but-set-global] old_got is only read in ppc_after_check_relocs, which is not generated for VxWorks. The --sdata-got option that sets it is not registered for VxWorks either. Move the variable and the handling of OPTION_OLD_GOT inside the existing non-VxWorks c…”

In Details

This patch modifies the ppc32elf.em linker template, which defines behavior for PowerPC 32-bit ELF targets. Specifically, it addresses a static variable old_got and the --sdata-got option. This variable is used in ppc_after_check_relocs, a function that is not generated for VxWorks targets. The build system's use of clang with -Wunused-but-set-global flags this unused variable. The change confines the old_got definition and its option parsing to when the target is not VxWorks, resolving the warning.

For Context
ld/ppc32elf
Refers to the linker script template for PowerPC 32-bit ELF targets within the GNU Binutils project.
VxWorks
A real-time operating system (RTOS) often used in embedded systems.
old_got
A variable likely related to the management of the Global Offset Table (GOT) in the linker, possibly for compatibility with older conventions.
GOT
Global Offset Table. A table used by position-independent executable code to store addresses of external functions and variables, allowing them to be resolved at runtime.
Filed Under: linkerPowerPCVxWorkscompiler warnings