binutils Newspaper
NOVEMBER 30, 2026
bfd/nds32 — Proposed

bfd/nds32: remove unused got_size variable

Removes an unused variable `got_size` from the BFD NDS32 backend after it was identified as unused and flagged by a compiler warning.

This patch removes the got_size variable from the BFD NDS32 backend code. The variable was found to be unused since its introduction in 2013, triggering a compiler warning with -Werror,-Wunused-but-set-global. The removal also simplifies the nds32_elf_late_size_sections function by merging empty branches related to .got and .got.plt handling with the .plt handling.

In the Thread 3 participants
  1. Simon Marchi proposer

    Proposes removing the `got_size` variable as it's unused and causing compiler warnings, also simplifying related code.

    “Building bfd with a recent clang fails with: /home/smarchi/src/binutils-gdb/bfd/elf32-nds32.c:154:13: error: variable 'got_size' set but not used [-Werror,-Wunused-but-set-global] The variable has been unused since it was introduced by commit 35c081572f32 ("Add support for Andes NDS32:", 2013-12-13). Remove it, along with the comment that describes it. The branches handling the .got and .…”
  2. Alan Modra reviewer

    Approves the removal of the unused variable and associated code simplification.

    “OK.”
  3. Simon Marchi proposer

    Confirms the patch has been applied.

Technical Tradeoffs

  • Removes dead code and simplifies linker logic.
  • Addresses compiler warnings.

In Details

This patch is a code cleanup for the BFD backend supporting the NDS32 architecture. It targets the elf32-nds32.c file to remove a global variable got_size, which has been unused since the initial NDS32 support was added. The compiler (Clang) flagged this variable with -Werror=unused-but-set-global. The removal also leads to a simplification of the nds32_elf_late_size_sections function, as the code blocks specifically handling .got and .got.plt sections, which were empty due to the unused variable, are merged into the handling for the .plt section.

For Context
BFD
Binary File Descriptor library. A low-level library used by binutils to abstract over various object file formats (like ELF, a.out, COFF).
NDS32
A 32-bit processor architecture developed by Andes Technology Corporation.
ELF
Executable and Linkable Format. A common standard file format for object files, executables, and shared libraries on Unix-like systems.
GOT
Global Offset Table. A table used by position-independent executable code to locate global variables and functions at runtime.
.got
The Global Offset Table section in an ELF object file.
.got.plt
A specific section within the GOT used for lazy binding of Procedure Linkage Table (PLT) entries.
.plt
The Procedure Linkage Table section in an ELF object file, used for dynamic linking.
unused-but-set-global
A compiler warning indicating that a global variable has been assigned a value but is never subsequently read or used.
Filed Under: cleanupbfdnds32compiler warningslinker script