[binutils-gdb] readelf.c: Use unsigned long to iterate over num_syms
H.J. Lu
hjl@sourceware.org
Thu Mar 19 12:25:49 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef3df11042c3dbaf695c1260b42364688cafa8ea
commit ef3df11042c3dbaf695c1260b42364688cafa8ea
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Mar 19 05:22:18 2020 -0700
readelf.c: Use unsigned long to iterate over num_syms
process_symbol_table () has
unsigned long num_syms;
...
for (si = 0, psym = symtab; si < num_syms; si++, psym++)
We should use unsigned long to iterate over num_syms.
* readelf.c (process_symbol_table): Use unsigned long for si.
Diff:
---
binutils/ChangeLog | 4 ++++
binutils/readelf.c | 7 +++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index f3405936923..d012f07f15b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2020-03-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ * readelf.c (process_symbol_table): Use unsigned long for si.
+
2020-03-19 Alan Modra <amodra@gmail.com>
* elfcomm.c: Don't include bfd.h or bucomm.h.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index f76b9f6d8e6..66d91a37b7a 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12001,12 +12001,11 @@ process_symbol_table (Filedata * filedata)
i < filedata->file_header.e_shnum;
i++, section++)
{
- unsigned int si;
char * strtab = NULL;
unsigned long int strtab_size = 0;
Elf_Internal_Sym * symtab;
Elf_Internal_Sym * psym;
- unsigned long num_syms;
+ unsigned long si, num_syms;
if ((section->sh_type != SHT_SYMTAB
&& section->sh_type != SHT_DYNSYM)
@@ -12060,7 +12059,7 @@ process_symbol_table (Filedata * filedata)
enum versioned_symbol_info sym_info;
unsigned short vna_other;
- printf ("%6d: ", si);
+ printf ("%6ld: ", si);
print_vma (psym->st_value, LONG_HEX);
putchar (' ');
print_vma (psym->st_size, DEC_5);
@@ -12106,7 +12105,7 @@ process_symbol_table (Filedata * filedata)
/* Solaris binaries have been found to violate this requirement as
well. Not sure if this is a bug or an ABI requirement. */
&& filedata->file_header.e_ident[EI_OSABI] != ELFOSABI_SOLARIS)
- warn (_("local symbol %u found at index >= %s's sh_info value of %u\n"),
+ warn (_("local symbol %lu found at index >= %s's sh_info value of %u\n"),
si, printable_section_name (filedata, section), section->sh_info);
}
More information about the Binutils-cvs
mailing list