Allow partial use of .dynsym when using dynamic symbols
Binutils BFD now correctly handles partial use of .dynsym for dynamic symbol tables.
This change adjusts the BFD library to correctly handle scenarios where the dynamic symbol table (.dynsym) is used partially. Previously, it enforced a strict equality check between the number of symbols and the dynamic symbol table count, which could lead to errors in valid use cases. The updated logic now allows for partial use, improving robustness when processing ELF files with dynamic linking.
In Details
In BFD's ELF support, bfd_elf_get_elf_syms handles symbol table retrieval. When elf_use_dt_symtab_p is true, it uses the dynamic symbol table. The previous check dt_symtab_count != symcount + symoffset was too strict. This commit refines the check to symoffset >= dt_symtab_count || symcount > dt_symtab_count - symoffset, which correctly accounts for the available symbols within the dynamic symbol table, accommodating cases where the symbol count does not exactly match the dynamic table size.
- .dynsym
- The dynamic symbol table section in an ELF file. It contains symbols that are needed for dynamic linking at runtime.
- ELF
- Executable and Linkable Format. A common standard file format for executables, object code, shared libraries, and core dumps on Unix-like systems.
- BFD
- Binary File Descriptor library. A library used by GNU Binutils to provide a generic interface for reading and writing various binary file formats, including ELF.