binutils Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
readelf

readelf.c: Fix gcc-4.9 compile error.

Fixes readelf.c compile error in GCC 4.9 due to empty struct initializer.

A compile error in readelf.c when using GCC 4.9 has been fixed. The error occurred because GCC 4.9 does not permit an empty initializer for a struct, specifically Elf_Internal_Shdr section = {};. This commit changes the initialization to use explicit field assignments, resolving the compilation issue.

In Details

This commit resolves a GCC 4.9 compilation error in binutils/readelf.c within the process_relocs function. The error [-Werror=missing-field-initializers] arises when an empty struct initializer {} is used for Elf_Internal_Shdr section. The fix rewrites the initialization to use designated initializers, ensuring compatibility with GCC 4.9's stricter requirements for empty initializers.

For Context
readelf
A utility that displays information about ELF object files, including section headers, symbol tables, and relocation entries.
ELF
Executable and Linkable Format. A file format used for executables, object code, shared libraries, and core dumps on Unix-like systems.
struct initializer
In C, a way to assign initial values to members of a struct variable upon declaration.
GCC 4.9
An older version of the GNU Compiler Collection, used as a compatibility target, highlighting a specific compiler behavior.
Elf_Internal_Shdr
An internal structure used by binutils to represent ELF section header information.
Filed Under: readelfGCCcompiler errorELF