readelf: Consolidate get_[32|64]bit_dynamic_section
Consolidates 32-bit and 64-bit dynamic section reading functions into a single function in readelf.
This patch consolidates the get_32bit_dynamic_section and get_64bit_dynamic_section functions in readelf.c into a single get_dynamic_section function. The new function is designed to handle both 32-bit and 64-bit ELF dynamic sections, using BYTE_GET_SIZE to retrieve external dynamic tags. This change aims to reduce code duplication and improve maintainability within the readelf utility, addressing PR binutils/34356.
In Details
This is the final patch in a series aimed at refactoring readelf's ELF section and program header parsing logic. It merges the separate 32-bit and 64-bit functions for reading the dynamic section (.dynamic) into a unified get_dynamic_section function. This consolidation simplifies the codebase by removing redundant code and standardizing the reading of external dynamic tags using BYTE_GET_SIZE. The change directly addresses PR binutils/34356.
- readelf
- A utility that displays information about ELF files, including dynamic section information.
- dynamic section
- An ELF section (typically named .dynamic) that contains information needed for dynamic linking, such as symbol tables, relocation entries, and library dependencies.
- ELF
- Executable and Linkable Format, a standard file format for executables, object code, shared libraries, and core dumps on many Unix-like systems.
- consolidation
- The process of merging multiple functions or code blocks into a single, more efficient one.
- BYTE_GET_SIZE
- A macro likely used to read a value of a specific size from a byte buffer and advance the buffer pointer.