Delete redundant check_relocs symndx upper bound checks
Removes unnecessary upper bound checks for symbol indices in check_relocs functions across multiple ELF backends.
This patch removes redundant checks for the upper bound of symbol indices (r_symndx) in the check_relocs function of numerous ELF backends. The _bfd_elf_link_read_relocs function, which is the source of relocations processed by check_relocs, already performs these upper bound checks. Therefore, duplicating this validation within check_relocs is unnecessary and has been removed to simplify the code.
- proposer
Proposes removing redundant upper bound checks for relocation symbol indices (`r_symndx`) from various ELF backend `check_relocs` functions, as these checks are already performed by `_bfd_elf_link_read_relocs`.
“_bfd_elf_link_read_relocs does these checks, and the relocs processed by check_relocs always come via that function.”
In Details
This patch targets multiple BFD ELF backend files (e.g., elf32-arm.c, elf64-x86-64.c, elfnn-loongarch.c) to remove checks for r_symndx >= nsyms or similar conditions within their respective check_relocs functions. The rationale is that _bfd_elf_link_read_relocs is the primary function that reads relocations, and it already validates that r_symndx is within the bounds of the symbol table size. This eliminates redundant checks and simplifies the check_relocs logic.
- 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 Index
- An integer that uniquely identifies a symbol within a symbol table.
- ELF
- Executable and Linkable Format. A standard file format for object files, executables, shared libraries, and core dumps on many Unix-like systems.
- _bfd_elf_link_read_relocs
- A BFD library function that reads relocation entries from an ELF object file's section.
- check_relocs
- A function within BFD's ELF backends responsible for validating relocation entries against symbol table information.