readelf section reading
authorAlan Modra <amodra@gmail.com>
Fri, 11 Jun 2021 04:42:07 +0000 (14:12 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 11 Jun 2021 04:42:07 +0000 (14:12 +0930)
commit4de91c10cdd9f5818599578667802320df305d72
treea546a8305091b6d1166e2ab3e22b1a2f5f99987b
parentf64b9b13ce4bb927f47a1fe0257c3794c6357c8c
readelf section reading

This is a followup to git commit 8ff66993e0b5, a patch aimed at
segfaults found invoking readelf multiple times with fuzzed objects.
In that patch I added code to clear more stashed data early in
process_section_headers, along with any stashed section headers.  This
patch instead relies on clearing out the stash at the end of
process_object, making sure that process_object doesn't exit early.

The patch also introduces some new wrapper functions.

* readelf.c (GET_ELF_SYMBOLS): Delete.  Replace with..
(get_elf_symbols): ..this new function throughout.
(get_32bit_section_headers): Don't free section_headers.
(get_64bit_section_headers): Likewise.
(get_section_headers): New function, use throughout in place of
32bit and 64bit variants.
(get_dynamic_section): Similarly.
(process_section_headers): Don't free filedata memory here.
(get_file_header): Don't get section headers here..
(process_object): ..Read them here instead.  Don't exit without
freeing filedata memory.
binutils/ChangeLog
binutils/readelf.c