This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PR25046, readelf "Reading xxx bytes extends past end of file for dynamic section"
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 30 Sep 2019 14:21:34 +0930
- Subject: PR25046, readelf "Reading xxx bytes extends past end of file for dynamic section"
process_object does
if (process_program_headers (filedata))
process_dynamic_section (filedata);
but process_program_headers can return true before clearing globals
used by process_dynamic_section, leaving stale data from a previous
file.
PR 25046
* readelf.c (process_program_headers): Clear dynamic_addr and
dynamic_size earlier.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index cc168163b2..0962877ad8 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5101,6 +5101,9 @@ process_program_headers (Filedata * filedata)
unsigned int i;
Elf_Internal_Phdr * previous_load = NULL;
+ dynamic_addr = 0;
+ dynamic_size = 0;
+
if (filedata->file_header.e_phnum == 0)
{
/* PR binutils/12467. */
@@ -5151,9 +5154,6 @@ process_program_headers (Filedata * filedata)
}
}
- dynamic_addr = 0;
- dynamic_size = 0;
-
for (i = 0, segment = filedata->program_headers;
i < filedata->file_header.e_phnum;
i++, segment++)
--
Alan Modra
Australia Development Lab, IBM