aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-06-22 05:17:55 +0000
committerAlan Modra <amodra@gmail.com>2004-06-22 05:17:55 +0000
commitfb514b26fa9986c7690da8da9c030ef030145b35 (patch)
treefc069e9b6824643b671ba615a77465966f88831e
parent929ba6e7ec15a3279678ba2841eb174f27761175 (diff)
downloadgdb-fb514b26fa9986c7690da8da9c030ef030145b35.zip
gdb-fb514b26fa9986c7690da8da9c030ef030145b35.tar.gz
gdb-fb514b26fa9986c7690da8da9c030ef030145b35.tar.bz2
* readelf.c (get_32bit_dynamic_section): Correct number of entries
translated from external to internal form. (get_64bit_dynamic_section): Likewise.
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/readelf.c26
2 files changed, 18 insertions, 14 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index f3d62b4..ba88282 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-22 Alan Modra <amodra@bigpond.net.au>
+
+ * 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 <zhangjie@magima.com.cn>
* readelf.c (process_program_headers): When locating the dynamic
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 609e586..2739877 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);