MSYS2-packages/mingw-w64-cross-binutils/0110-binutils-mingw-gnu-print.patch
2022-01-15 13:13:37 -05:00

182 lines
6.4 KiB
Diff

From 5ee25363627a01704e38cc828e745065982cb3a3 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Wed, 28 Jul 2021 21:47:18 +0200
Subject: [PATCH] mingw printf
---
bfd/bfd-in.h | 2 +-
bfd/bfd-in2.h | 2 +-
binutils/dwarf.c | 2 +-
binutils/nm.c | 2 +-
binutils/prdbg.c | 2 +-
binutils/strings.c | 6 +++---
gas/as.h | 4 ++--
gold/configure | 2 +-
gold/configure.ac | 2 +-
include/ansidecl.h | 4 ++--
10 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index a4888f9f7f2..85540462b15 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -126,7 +126,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
#if BFD_HOST_64BIT_LONG
#define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined(__MSVCRT__) && !defined( __USE_MINGW_ANSI_STDIO)
#define BFD_VMA_FMT "I64"
#else
#define BFD_VMA_FMT "ll"
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 9a698316980..4a9d597d60e 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -133,7 +133,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
#if BFD_HOST_64BIT_LONG
#define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined (__MSVCRT__) && !defined(__USE_MINGW_ANSI_STDIO)
#define BFD_VMA_FMT "I64"
#else
#define BFD_VMA_FMT "ll"
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 1e7f4db7b7c..f33de2a649e 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -218,7 +218,7 @@ get_encoded_value (unsigned char **pdata,
}
#if SIZEOF_LONG_LONG > SIZEOF_LONG
-# ifndef __MINGW32__
+# ifndef __MINGW32__ || defined(__USE_MINGW_ANSI_STDIO)
# define DWARF_VMA_FMT "ll"
# define DWARF_VMA_FMT_LONG "%16.16llx"
# else
diff --git a/binutils/nm.c b/binutils/nm.c
index 82ccec6801c..4925ea580dc 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -1312,7 +1312,7 @@ get_print_format (void)
#if BFD_HOST_64BIT_LONG
;
#elif BFD_HOST_64BIT_LONG_LONG
-#ifndef __MSVCRT__
+#if !defined(__MSVCRT__) || defined(__USE_MINGW_ANSI_STDIO)
length = "ll";
#else
length = "I64";
diff --git a/binutils/prdbg.c b/binutils/prdbg.c
index 6c14dcac9a8..bedfffa022e 100644
--- a/binutils/prdbg.c
+++ b/binutils/prdbg.c
@@ -497,7 +497,7 @@ print_vma (bfd_vma vma, char *buf, bool unsignedp, bool hexp)
#if BFD_HOST_64BIT_LONG_LONG
else if (sizeof (vma) <= sizeof (unsigned long long))
{
-#ifndef __MSVCRT__
+#if !defined(__MSVCRT__) || defined(__USE_MINGW_ANSI_STDIO)
if (hexp)
sprintf (buf, "0x%llx", (unsigned long long) vma);
else if (unsignedp)
diff --git a/binutils/strings.c b/binutils/strings.c
index 44a8e1da644..4010829dc49 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -610,7 +610,7 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
case 8:
if (sizeof (start) > sizeof (long))
{
-#ifndef __MSVCRT__
+#if !defined(__MSVCRT__) || defined(__USE_MINGW_ANSI_STDIO)
printf ("%7llo ", (unsigned long long) start);
#else
printf ("%7I64o ", (unsigned long long) start);
@@ -623,7 +623,7 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
case 10:
if (sizeof (start) > sizeof (long))
{
-#ifndef __MSVCRT__
+#if !defined(__MSVCRT__) || defined(__USE_MINGW_ANSI_STDIO)
printf ("%7llu ", (unsigned long long) start);
#else
printf ("%7I64d ", (unsigned long long) start);
@@ -636,7 +636,7 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
case 16:
if (sizeof (start) > sizeof (long))
{
-#ifndef __MSVCRT__
+#if !defined(__MSVCRT__) || defined(__USE_MINGW_ANSI_STDIO)
printf ("%7llx ", (unsigned long long) start);
#else
printf ("%7I64x ", (unsigned long long) start);
diff --git a/gas/as.h b/gas/as.h
index 14a768f8889..b1f056f115a 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -405,10 +405,10 @@ typedef struct _pseudo_type pseudo_typeS;
#define PRINTF_LIKE(FCN) \
void FCN (const char *format, ...) \
- __attribute__ ((__format__ (__printf__, 1, 2)))
+ __attribute__ ((__format__ (gnu_printf, 1, 2)))
#define PRINTF_WHERE_LIKE(FCN) \
void FCN (const char *file, unsigned int line, const char *format, ...) \
- __attribute__ ((__format__ (__printf__, 3, 4)))
+ __attribute__ ((__format__ (gnu_printf, 3, 4)))
#else /* __GNUC__ < 2 || defined(VMS) */
diff --git a/gold/configure b/gold/configure
index b9f062b68eb..fde982191c5 100755
--- a/gold/configure
+++ b/gold/configure
@@ -10153,7 +10153,7 @@ else
/* end confdefs.h. */
template<typename T> extern void foo(const char*, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ __attribute__ ((__format__ (gnu_printf, 1, 2)));
template<typename T> void foo(const char* format, ...) {}
void bar() { foo<int>("%s\n", "foo"); }
diff --git a/gold/configure.ac b/gold/configure.ac
index 1716a779416..cae29866f38 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -678,7 +678,7 @@ AC_CACHE_CHECK([whether we can use attributes with template functions],
[gold_cv_template_attribute],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
template<typename T> extern void foo(const char*, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
+ __attribute__ ((__format__ (gnu_printf, 1, 2)));
template<typename T> void foo(const char* format, ...) {}
void bar() { foo<int>("%s\n", "foo"); }
])], [gold_cv_template_attribute=yes], [gold_cv_template_attribute=no])])
diff --git a/include/ansidecl.h b/include/ansidecl.h
index 0515228f325..7c2b9f18306 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -195,7 +195,7 @@ So instead we use the macro below and test it against specific values. */
before GCC 3.3, but as of 3.3 we need to add the `nonnull'
attribute to retain this behavior. */
#ifndef ATTRIBUTE_PRINTF
-#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
+#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (gnu_printf, m, n))) ATTRIBUTE_NONNULL(m)
#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
@@ -223,7 +223,7 @@ So instead we use the macro below and test it against specific values. */
NULL format specifier was allowed as of gcc 3.3. */
#ifndef ATTRIBUTE_NULL_PRINTF
# if (GCC_VERSION >= 3003)
-# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
+# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (gnu_printf, m, n)))
# else
# define ATTRIBUTE_NULL_PRINTF(m, n)
# endif /* GNUC >= 3.3 */
--
2.32.0