This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch bfd]: Fix printf formatter for mingw 1 of N
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Binutils <binutils at sourceware dot org>
- Cc: Nick Clifton <nickc at redhat dot com>
- Date: Wed, 10 Oct 2012 16:35:00 +0200
- Subject: [patch bfd]: Fix printf formatter for mingw 1 of N
Hello,
this is first patch addressing this issue. There are several other
places where similiar issues are happening (see use of %z, %lld, and
%llx in bfd, binutils, and opcode sources). There are are several
different ways to resolve these issue. First would be to add - as
done by this patch - include of inttypes.h - if available - and use
int64_t here instead 'long long' type. Second would be to add those
helper macros to bfd-in.h (eg BFD_PRI64 and bfd_int64_t/bfd_uint64_t).
Another variant would be to use in binutils the gnulib existing for
gdb for now. The fourth solution would be to enable for mingw-targets
by default POSIX-printf, which of course don't resolve the issue for
VC.
So I would like to get your opinion, which variant is preferred by
binutils community to resolve this printf-formatting issue.
ChangeLog
2012-10-10 Kai Tietz
* coff-rs600.c (FMT20): Use
PRId64 macro, if available.
(FMT20_type): New.
Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
x86_64-unknown-linux-gnu. Ok for apply?
Regards,
Kai
Index: coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.107
diff -u -3 -r1.107 coff-rs6000.c
--- coff-rs6000.c 20 Aug 2012 14:32:30 -0000 1.107
+++ coff-rs6000.c 10 Oct 2012 14:21:03 -0000
@@ -1758,12 +1758,19 @@
}
static char buff20[XCOFFARMAGBIG_ELEMENT_SIZE + 1];
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#define FMT20 "%-20" PRId64
+#define FMT20_type intptr_t
+#else
#define FMT20 "%-20lld"
+#define FMT20_type long long
+#endif
#define FMT12 "%-12d"
#define FMT12_OCTAL "%-12o"
#define FMT4 "%-4d"
#define PRINT20(d, v) \
- sprintf (buff20, FMT20, (long long)(v)), \
+ sprintf (buff20, FMT20, (FMT20_type)(v)), \
memcpy ((void *) (d), buff20, 20)
#define PRINT12(d, v) \
I would like to get your opinion