binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
readelf

Fold -bit dynamic section parsing into a single function

Unified dynamic section parsing in readelf, reducing code duplication.

The readelf utility now uses a single function to parse both 32-bit and 64-bit dynamic sections. 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_dynamic_section and get_64bit_dynamic_section functions into a single ElfXX(_get_dynamic_section) 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. This addresses PR binutils/34356 by reducing code duplication and simplifying maintenance.

For Context
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.
dynamic section
An ELF section containing information necessary for dynamic linking, such as symbols to be resolved at runtime, the dynamic loader, and relocation entries.
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.
Filed Under: binutilsreadelfelfoptimizationrefactoring