From: Mark Wielaard Date: Fri, 8 Jan 2016 15:45:12 +0000 (+0100) Subject: Fix build on 32bit systems. X-Git-Tag: elfutils-0.165~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a5fc51573ae88a06d2050ef8425336e23013852;p=thirdparty%2Felfutils.git Fix build on 32bit systems. size_t has a different size on 32 and 64 bit systems. Signed-off-by: Mark Wielaard --- diff --git a/src/ChangeLog b/src/ChangeLog index ae2129d96..af98c4ded 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2016-01-08 Mark Wielaard + + * elfcompress.c (compress_section): Use %zu to print size_t. + * readelf.c (print_shdr): Use %zx to print size_t. + 2015-12-16 Mark Wielaard * elfcompress.c: New file. diff --git a/src/elfcompress.c b/src/elfcompress.c index 5be2375d5..23939db8b 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -237,7 +237,7 @@ compress_section (Elf_Scn *scn, size_t orig_size, const char *name, } float new = shdr->sh_size; float orig = orig_size ?: 1; - printf (" (%" PRIu64 " => %" PRIu64 " %.2f%%)\n", + printf (" (%zu => %" PRIu64 " %.2f%%)\n", orig_size, shdr->sh_size, (new / orig) * 100); } } diff --git a/src/readelf.c b/src/readelf.c index 85fa92bc5..0db192ee4 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1217,7 +1217,7 @@ There are %d section headers, starting at offset %#" PRIx64 ":\n\ { ssize_t size; if ((size = dwelf_scn_gnu_compressed_size (scn)) >= 0) - printf (" [GNU ZLIB %0*" PRIx64 " ]\n", + printf (" [GNU ZLIB %0*zx ]\n", ehdr->e_ident[EI_CLASS] == ELFCLASS32 ? 6 : 8, size); else error (0, 0, diff --git a/tests/ChangeLog b/tests/ChangeLog index 453c41861..3d9353c43 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2016-01-08 Mark Wielaard + + * elfputzdata.c (main): Use PRId64 to print 64 bit value. + 2016-01-08 Mark Wielaard * Makefile.am (TESTS): Always unconditionally add diff --git a/tests/elfputzdata.c b/tests/elfputzdata.c index 7e6f01145..67c609087 100644 --- a/tests/elfputzdata.c +++ b/tests/elfputzdata.c @@ -90,7 +90,7 @@ main (int argc, char *argv[]) else { size_t orig_size = shdr->sh_size; - printf ("Lets compress %zd %s, size: %zd\n", + printf ("Lets compress %zd %s, size: %" PRId64 "\n", idx, name, shdr->sh_size); Elf_Data *d = elf_getdata (scn, NULL); if (d == NULL)