Fold -bit ELF symbol parsing into a single function
Unified ELF symbol parsing in readelf, reducing code duplication.
The readelf utility now uses a single function to parse both 32-bit and 64-bit ELF symbol tables. This is achieved by using conditional compilation within readelf-nn.c, effectively compiling the same code twice with different types to avoid duplicating the parsing logic, addressing PR binutils/34356.
In Details
This commit folds the separate get_32bit_elf_symbols and get_64bit_elf_symbols functions into a single ElfXX(_get_symbols) function defined in binutils/readelf-nn.c. The ElfXX macro ensures this code is compiled twice, once for 32-bit and once for 64-bit, handling the type differences and slight variations in field order. This addresses PR binutils/34356 by reducing code duplication and simplifying maintenance.
- readelf
- A utility in GNU Binutils that displays information about ELF (Executable and Linkable Format) files. It can show details about sections, symbols, dynamic linking information, and more.
- ELF
- Executable and Linkable Format. A common standard file format for executables, object code, shared libraries, and core dumps on Unix-like operating systems.
- symbol table
- A data structure within an object file or executable that lists the symbols (e.g., function names, variable names) defined or referenced by the code, along with their addresses or other attributes.
- code duplication
- Occurs when the same or very similar code is repeated in multiple places within a codebase. Reducing code duplication improves maintainability and reduces the chance of errors.
- PR binutils/34356
- A reference to a specific bug report (Problem Report) filed against the Binutils project. This commit is a fix or improvement related to that report.