From fb514b26fa9986c7690da8da9c030ef030145b35 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 22 Jun 2004 05:17:55 +0000 Subject: [PATCH] * readelf.c (get_32bit_dynamic_section): Correct number of entries translated from external to internal form. (get_64bit_dynamic_section): Likewise. --- binutils/ChangeLog | 6 ++++++ binutils/readelf.c | 26 ++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index f3d62b45f6a..ba8828265ba 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2004-06-22 Alan Modra + + * readelf.c (get_32bit_dynamic_section): Correct number of entries + translated from external to internal form. + (get_64bit_dynamic_section): Likewise. + 2004-06-18 Jie Zhang * readelf.c (process_program_headers): When locating the dynamic diff --git a/binutils/readelf.c b/binutils/readelf.c index 609e586921d..27398775561 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -4656,9 +4656,8 @@ dynamic_section_ia64_val (Elf_Internal_Dyn *entry) static int get_32bit_dynamic_section (FILE *file) { - Elf32_External_Dyn *edyn; + Elf32_External_Dyn *edyn, *ext; Elf_Internal_Dyn *entry; - bfd_size_type i; edyn = get_data (NULL, file, dynamic_addr, dynamic_size, _("dynamic section")); @@ -4674,12 +4673,12 @@ get_32bit_dynamic_section (FILE *file) return 0; } - for (i = 0, entry = dynamic_section; - i < dynamic_size; - i++, entry++) + for (ext = edyn, entry = dynamic_section; + (char *) ext < (char *) edyn + dynamic_size; + ext++, entry++) { - entry->d_tag = BYTE_GET (edyn[i].d_tag); - entry->d_un.d_val = BYTE_GET (edyn[i].d_un.d_val); + entry->d_tag = BYTE_GET (ext->d_tag); + entry->d_un.d_val = BYTE_GET (ext->d_un.d_val); } free (edyn); @@ -4690,9 +4689,8 @@ get_32bit_dynamic_section (FILE *file) static int get_64bit_dynamic_section (FILE *file) { - Elf64_External_Dyn *edyn; + Elf64_External_Dyn *edyn, *ext; Elf_Internal_Dyn *entry; - bfd_size_type i; edyn = get_data (NULL, file, dynamic_addr, dynamic_size, _("dynamic section")); @@ -4708,12 +4706,12 @@ get_64bit_dynamic_section (FILE *file) return 0; } - for (i = 0, entry = dynamic_section; - i < dynamic_size; - i++, entry++) + for (ext = edyn, entry = dynamic_section; + (char *) ext < (char *) edyn + dynamic_size; + ext++, entry++) { - entry->d_tag = BYTE_GET8 (edyn[i].d_tag); - entry->d_un.d_val = BYTE_GET8 (edyn[i].d_un.d_val); + entry->d_tag = BYTE_GET8 (ext->d_tag); + entry->d_un.d_val = BYTE_GET8 (ext->d_un.d_val); } free (edyn); -- 2.30.2