binutils Newspaper
NOVEMBER 30, 2026
binutils — Proposed

Remove dead code in arm check_relocs

Removes unnecessary check for zero symbols in the ARM ELF check_relocs function.

This patch removes dead code from the elf32_arm_check_relocs function in BFD. Specifically, it eliminates a check for zero symbols (nsyms), which is no longer necessary because the library now rejects object files with relocations that lack a proper symbol table. This simplifies the function and removes outdated logic.

In the Thread 1 participant
  1. Alan Modra <amodra@gmail.com> proposer

    Removes dead code from `elf32_arm_check_relocs` that checked for zero symbols, as this condition is now handled by earlier validation.

    “Now that we reject object files with relocs lacking a proper .symtab section, checking for zero nsyms is no longer necessary.”

In Details

In bfd/elf32-arm.c, this patch removes the nsyms variable and its initialization, along with the conditional block that used it to distinguish between local symbols and global hash table entries. This simplification is possible because a prior change ensures that relocations are only processed if a valid symbol table exists, making the nsyms > 0 check redundant. The logic now directly uses r_symndx < symtab_hdr->sh_info to determine if a symbol is local.

For Context
Relocation
A modification needed in an object file or shared library to resolve references to symbols or addresses that are not yet known at link time. This process is typically handled by the linker.
Symbol Table
A data structure within an object file or executable that maps symbol names to their addresses and other attributes, used by linkers and debuggers.
.symtab
The section in an ELF object file that contains the symbol table, mapping symbol names to their addresses and attributes.
Dead Code
Code that is never executed or whose execution has no effect on the outcome of the program. Removing dead code simplifies maintenance and can sometimes improve performance.
ARM
Advanced RISC Machine. A family of reduced instruction set computing (RISC) architectures for computer processors, widely used in mobile devices and embedded systems.
Filed Under: dead-code-removalrefactoringbinutils