This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Committed: fix %lx format used with bfd_size_type mismatch in readelf.c


The commit f54498b4 introduced code that uses the %lx format with
bfd_size_type parameters.  Ungood.  Causes for builds where
bfd_size_type isn't "long" (gcc -m32):

gcc -m32 -DHAVE_CONFIG_H -I. -I/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils  -I. -I/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils -I../bfd -I/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/../bfd -I/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT readelf.o -MD -MP -MF .deps/readelf.Tpo -c -o readelf.o /expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/readelf.c
cc1: warnings being treated as errors
/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/readelf.c: In function 'get_32bit_elf_symbols':
/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/readelf.c:4593: error: format '%lx' expects type 'long unsigned int', but argument 3 has type 'bfd_size_type'
/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/readelf.c: In function 'get_64bit_elf_symbols':
/expvol/pp_slask/hp/checkout/binutils-gdb-git/binutils/readelf.c:4680: error: format '%lx' expects type 'long unsigned int', but argument 3 has type 'bfd_size_type'
make[4]: Leaving directory `/tmp/x/binutils'
make[4]: *** [readelf.o] Error 1

Elsewhere %lx is used, the argument is cast appropriately.
Committed as obvious after testing.

binutils:
	* readelf.c (get_32bit_elf_symbols): Cast error
	parameters of bfd_size_type with the %lx format to
	unsigned long.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 6ddc078..6bbb61f 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4590,7 +4590,7 @@ get_32bit_elf_symbols (FILE * file,
   if (section->sh_size > current_file_size)
     {
       error (_("Section %s has an invalid sh_size of 0x%lx\n"),
-	     SECTION_NAME (section), section->sh_size);
+	     SECTION_NAME (section), (unsigned long) section->sh_size);
       goto exit_point;
     }
 
@@ -4677,7 +4677,7 @@ get_64bit_elf_symbols (FILE * file,
   if (section->sh_size > current_file_size)
     {
       error (_("Section %s has an invalid sh_size of 0x%lx\n"),
-	     SECTION_NAME (section), section->sh_size);
+	     SECTION_NAME (section), (unsigned long) section->sh_size);
       goto exit_point;
     }
 

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]