[COMMITTED, PATCH] readelf: Avoid may be used uninitialized warning from GCC 14
H.J. Lu
hjl.tools@gmail.com
Wed Jul 1 23:13:48 GMT 2026
On Thu, Jul 2, 2026 at 6:21 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Jul 1, 2026 at 2:21 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > PR binutils/34324
> > * readelf.c (process_relocs): Return error on missing DT_REL and
> > DT_RELA dynamic tags.
> >
>
> I am checking it in as an obvious fix.
GCC 14 fails to recognize that rel_entsz and entsz_name are unused when
process_relocs returns early for error:
.../binutils/readelf.c:10127:18: error: ‘rel_entsz’ may be used
uninitialized [-Werror=maybe-uninitialized]
10127 | if (rel_entsz == 0)
| ^
...
.../binutils/readelf.c:10129:19: error: ‘entsz_name’ may be used
uninitialized [-Werror=maybe-uninitialized]
10129 | printf (_("<missing or corrupt dynamic tag: %s>\n"),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10130 | entsz_name);
Clear them before returning error. Also replace reltype_unknown with
default since GCC 14 fails to see that reltype_unknown is the only
unhandled value for relocation_type enum.
PR binutils/34324
* readelf.c (process_relocs): Clear rel_entsz and entsz_name
before returning error on missing DT_REL and DT_RELA dynamic
tags.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-readelf-Avoid-may-be-used-uninitialized-warning-from.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260702/b1fd188a/attachment-0001.bin>
More information about the Binutils
mailing list