readelf.c: Use unsigned long to iterate over num_syms

Message ID 20200319112718.169371-1-hjl.tools@gmail.com
State New
Headers show
Series
  • readelf.c: Use unsigned long to iterate over num_syms
Related show

Commit Message

H.J. Lu via Binutils March 19, 2020, 11:27 a.m.
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.
---
 binutils/readelf.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

-- 
2.25.1

Patch

diff --git a/binutils/readelf.c b/binutils/readelf.c
index dfdf06c387..0a81d46339 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12034,12 +12034,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)
@@ -12093,7 +12092,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);
@@ -12139,7 +12138,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);
 	    }