readelf section reading

Alan Modra amodra@gmail.com
Sat Jun 12 02:39:18 GMT 2021


On Sat, Jun 12, 2021 at 11:01:33AM +0930, Alan Modra wrote:
> On Fri, Jun 11, 2021 at 05:33:12PM +0930, Alan Modra wrote:
> Fix commit 4de91c10cdd9, which cached the single section header read
> to pick up file header extension fields.

Hmm, no it didn't.  We had this one tucked away in
process_file_header.  Some of the paths through readelf read all the
section headers, eg. open_file.  process_file_header shouldn't be
throwing away the section headers in those cases.

	* readelf.c (process_file_header): Don't clear section_headers.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4217ea3b5b0..79724e05494 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5237,8 +5237,6 @@ process_file_header (Filedata * filedata)
 	header->e_shstrndx = filedata->section_headers[0].sh_link;
       if (header->e_shstrndx >= header->e_shnum)
 	header->e_shstrndx = SHN_UNDEF;
-      free (filedata->section_headers);
-      filedata->section_headers = NULL;
     }
 
   return true;


-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list