size_t has a different size on 32 and 64 bit systems. Signed-off-by: Mark Wielaard <m...@redhat.com> --- src/ChangeLog | 5 +++++ src/elfcompress.c | 2 +- src/readelf.c | 2 +- tests/ChangeLog | 4 ++++ tests/elfputzdata.c | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog index ae2129d..af98c4d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2016-01-08 Mark Wielaard <m...@redhat.com> + + * 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 <m...@redhat.com> * elfcompress.c: New file. diff --git a/src/elfcompress.c b/src/elfcompress.c index 5be2375..23939db 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 85fa92b..0db192e 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 453c418..3d9353c 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,9 @@ 2016-01-08 Mark Wielaard <m...@redhat.com> + * elfputzdata.c (main): Use PRId64 to print 64 bit value. + +2016-01-08 Mark Wielaard <m...@redhat.com> + * Makefile.am (TESTS): Always unconditionally add run-readelf-zdebug.sh and run-readelf-zdebug-rel.sh. diff --git a/tests/elfputzdata.c b/tests/elfputzdata.c index 7e6f011..67c6090 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) -- 2.5.0