[PATCH] readelf: Save and dump the original section header values

H.J. Lu hjl.tools@gmail.com
Fri Jul 3 14:30:14 GMT 2026


validate_section_info clears the garbage values in the section header
to avoid crash later.  Save and dump the original section header values
to make the garbage values in the section header visible when dumping
section headers.

* readelf.c (filedata): Add orig_section_headers.
(validate_section_info): Add a pointer to the original section
header and save the original section header values.
(get_32bit_section_headers): Allocate the original section header
buffer.  Pass the original section header pointer to
validate_section_info.
(get_64bit_section_headers): Likewise.
(process_section_headers): Dump the original section headers.
(process_relocs): Pass a dummy original section pointer to
validate_section_info.
(free_filedata): Free filedata->orig_section_headers.
* testsuite/binutils-all/corrupt-1.elf.bz2: New file.
* testsuite/binutils-all/corrupt-1.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run corrupt-1.elf test.


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-readelf-Save-and-dump-the-original-section-header-va.patch
Type: text/x-patch
Size: 8970 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260703/19106a93/attachment.bin>


More information about the Binutils mailing list