Rewrite bfd error handler
authorAlan Modra <amodra@gmail.com>
Thu, 13 Apr 2017 01:28:40 +0000 (10:58 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 13 Apr 2017 07:37:24 +0000 (17:07 +0930)
This steals _doprnt from libiberty, extended to handle %A and %B.
Which lets us do away with the current horrible %A and %B handling
that requires all %A and %B arguments to be passed first, rather than
in the natural order.

* bfd.c (PRINT_TYPE): Define.
(_doprnt): New function.
(error_handler_internal): Use _doprnt.
* coff-arm.c: Put %A and %B arguments to _bfd_error_handler
calls in their natural order, throughout file.
* coff-mcore.c: Likewise.
* coff-ppc.c: Likewise.
* coff-tic80.c: Likewise.
* cofflink.c: Likewise.
* elf-s390-common.c: Likewise.
* elf.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-spu.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.

21 files changed:
bfd/ChangeLog
bfd/bfd.c
bfd/coff-arm.c
bfd/coff-mcore.c
bfd/coff-ppc.c
bfd/coff-tic80.c
bfd/cofflink.c
bfd/elf-s390-common.c
bfd/elf.c
bfd/elf32-arm.c
bfd/elf32-i386.c
bfd/elf32-m32r.c
bfd/elf32-msp430.c
bfd/elf32-spu.c
bfd/elf64-ia64-vms.c
bfd/elf64-sparc.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfnn-aarch64.c
bfd/elfnn-ia64.c
bfd/elfxx-mips.c

index 09578f1..b8a218f 100644 (file)
@@ -1,5 +1,31 @@
 2017-04-13  Alan Modra  <amodra@gmail.com>
 
+       * bfd.c (PRINT_TYPE): Define.
+       (_doprnt): New function.
+       (error_handler_internal): Use _doprnt.
+       * coff-arm.c: Put %A and %B arguments to _bfd_error_handler
+       calls in their natural order, throughout file.
+       * coff-mcore.c: Likewise.
+       * coff-ppc.c: Likewise.
+       * coff-tic80.c: Likewise.
+       * cofflink.c: Likewise.
+       * elf-s390-common.c: Likewise.
+       * elf.c: Likewise.
+       * elf32-arm.c: Likewise.
+       * elf32-i386.c: Likewise.
+       * elf32-m32r.c: Likewise.
+       * elf32-msp430.c: Likewise.
+       * elf32-spu.c: Likewise.
+       * elf64-ia64-vms.c: Likewise.
+       * elf64-sparc.c: Likewise.
+       * elf64-x86-64.c: Likewise.
+       * elflink.c: Likewise.
+       * elfnn-aarch64.c: Likewise.
+       * elfnn-ia64.c: Likewise.
+       * elfxx-mips.c: Likewise.
+
+2017-04-13  Alan Modra  <amodra@gmail.com>
+
        * elf32-arm.c (arm_type_of_stub): Supply missing args to "long
        branch veneers" error.  Fix double space and format message.
        * elf32-avr.c (avr_add_stub): Do not pass NULL as %B arg.
index a9402e4..23a4350 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -611,176 +611,240 @@ CODE_FRAGMENT
 
 static const char *_bfd_error_program_name;
 
-/* This is the default routine to handle BFD error messages.
-   Like fprintf (stderr, ...), but also handles some extra format specifiers.
-
-   %A section name from section.  For group components, print group name too.
-   %B file name from bfd.  For archive components, prints archive too.
-
-   Note - because these two extra format specifiers require special handling
-   they are scanned for and processed in this function, before calling
-   vfprintf.  This means that the *arguments* for these format specifiers
-   must be the first ones in the variable argument list, regardless of where
-   the specifiers appear in the format string.  Thus for example calling
-   this function with a format string of:
-
-      "blah %s blah %A blah %d blah %B"
-
-   would involve passing the arguments as:
-
-      "blah %s blah %A blah %d blah %B",
-        asection_for_the_%A,
-       bfd_for_the_%B,
-       string_for_the_%s,
-       integer_for_the_%d);
- */
-
-static void
-error_handler_internal (const char *fmt, va_list ap)
+/* This macro and _doprnt taken from libiberty _doprnt.c, tidied a
+   little and extended to handle '%A' and '%B'.  */
+
+#define PRINT_TYPE(TYPE) \
+  do                                                           \
+    {                                                          \
+      TYPE value = va_arg (ap, TYPE);                          \
+      result = fprintf (stream, specifier, value);             \
+    } while (0)
+
+static int
+_doprnt (FILE *stream, const char *format, va_list ap)
 {
-  char *bufp;
-  const char *new_fmt, *p;
-  size_t avail = 1000;
-  char buf[1000];
-
-  /* PR 4992: Don't interrupt output being sent to stdout.  */
-  fflush (stdout);
+  const char *ptr = format;
+  char specifier[128];
+  int total_printed = 0;
 
-  if (_bfd_error_program_name != NULL)
-    fprintf (stderr, "%s: ", _bfd_error_program_name);
-  else
-    fprintf (stderr, "BFD: ");
-
-  new_fmt = fmt;
-  bufp = buf;
-
-  /* Reserve enough space for the existing format string.  */
-  avail -= strlen (fmt) + 1;
-  if (avail > 1000)
-    _exit (EXIT_FAILURE);
-
-  p = fmt;
-  while (1)
+  while (*ptr != '\0')
     {
-      char *q;
-      size_t len, extra, trim;
+      int result;
 
-      p = strchr (p, '%');
-      if (p == NULL || p[1] == '\0')
+      if (*ptr != '%')
        {
-         if (new_fmt == buf)
-           {
-             len = strlen (fmt);
-             memcpy (bufp, fmt, len + 1);
-           }
-         break;
+         /* While we have regular characters, print them.  */
+         char *end = strchr (ptr, '%');
+         if (end != NULL)
+           result = fprintf (stream, "%.*s", (int) (end - ptr), ptr);
+         else
+           result = fprintf (stream, "%s", ptr);
+         ptr += result;
        }
-
-      if (p[1] == 'A' || p[1] == 'B')
+      else
        {
-         len = p - fmt;
-         memcpy (bufp, fmt, len);
-         bufp += len;
-         fmt = p + 2;
-         new_fmt = buf;
-
-         /* If we run out of space, tough, you lose your ridiculously
-            long file or section name.  It's not safe to try to alloc
-            memory here;  We might be printing an out of memory message.  */
-         if (avail == 0)
+         /* We have a format specifier!  */
+         char *sptr = specifier;
+         int wide_width = 0, short_width = 0;
+
+         /* Copy the % and move forward.  */
+         *sptr++ = *ptr++;
+
+         /* Move past flags.  */
+         while (strchr ("-+ #0", *ptr))
+           *sptr++ = *ptr++;
+
+         if (*ptr == '*')
            {
-             *bufp++ = '*';
-             *bufp++ = '*';
-             *bufp = '\0';
+             int value = abs (va_arg (ap, int));
+             sptr += sprintf (sptr, "%d", value);
+             ptr++;
            }
          else
+           /* Handle explicit numeric value.  */
+           while (ISDIGIT (*ptr))
+             *sptr++ = *ptr++;
+
+         if (*ptr == '.')
            {
-             if (p[1] == 'B')
+             /* Copy and go past the period.  */
+             *sptr++ = *ptr++;
+             if (*ptr == '*')
                {
-                 bfd *abfd = va_arg (ap, bfd *);
-
-                 if (abfd == NULL)
-                   /* Invoking %B with a null bfd pointer is an internal error.  */
-                   abort ();
-                 else if (abfd->my_archive
-                          && !bfd_is_thin_archive (abfd->my_archive))
-                   snprintf (bufp, avail, "%s(%s)",
-                             abfd->my_archive->filename, abfd->filename);
-                 else
-                   snprintf (bufp, avail, "%s", abfd->filename);
+                 int value = abs (va_arg (ap, int));
+                 sptr += sprintf (sptr, "%d", value);
+                 ptr++;
                }
              else
+               /* Handle explicit numeric value.  */
+               while (ISDIGIT (*ptr))
+                 *sptr++ = *ptr++;
+           }
+         while (strchr ("hlL", *ptr))
+           {
+             switch (*ptr)
                {
-                 asection *sec = va_arg (ap, asection *);
-                 bfd *abfd;
-                 const char *group = NULL;
-                 struct coff_comdat_info *ci;
-
-                 if (sec == NULL)
-                   /* Invoking %A with a null section pointer is an internal error.  */
-                   abort ();
-                 abfd = sec->owner;
-                 if (abfd != NULL
-                     && bfd_get_flavour (abfd) == bfd_target_elf_flavour
-                     && elf_next_in_group (sec) != NULL
-                     && (sec->flags & SEC_GROUP) == 0)
-                   group = elf_group_name (sec);
-                 else if (abfd != NULL
-                          && bfd_get_flavour (abfd) == bfd_target_coff_flavour
-                          && (ci = bfd_coff_get_comdat_section (sec->owner,
-                                                                sec)) != NULL)
-                   group = ci->name;
-                 if (group != NULL)
-                   snprintf (bufp, avail, "%s[%s]", sec->name, group);
-                 else
-                   snprintf (bufp, avail, "%s", sec->name);
-               }
-             len = strlen (bufp);
-             avail = avail - len + 2;
-
-             /* We need to replace any '%' we printed by "%%".
-                First count how many.  */
-             q = bufp;
-             bufp += len;
-             extra = 0;
-             while ((q = strchr (q, '%')) != NULL)
-               {
-                 ++q;
-                 ++extra;
+               case 'h':
+                 short_width = 1;
+                 break;
+               case 'l':
+                 wide_width++;
+                 break;
+               case 'L':
+                 wide_width = 2;
+                 break;
+               default:
+                 abort();
                }
+             *sptr++ = *ptr++;
+           }
 
-             /* If there isn't room, trim off the end of the string.  */
-             q = bufp;
-             bufp += extra;
-             if (extra > avail)
-               {
-                 trim = extra - avail;
-                 bufp -= trim;
-                 do
-                   {
-                     if (*--q == '%')
-                       --extra;
-                   }
-                 while (--trim != 0);
-                 *q = '\0';
-                 avail = extra;
-               }
-             avail -= extra;
+         /* Copy the type specifier, and NULL terminate.  */
+         *sptr++ = *ptr++;
+         *sptr = '\0';
 
-             /* Now double all '%' chars, shuffling the string as we go.  */
-             while (extra != 0)
-               {
-                 while ((q[extra] = *q) != '%')
-                   --q;
-                 q[--extra] = '%';
-                 --q;
-               }
+         switch (ptr[-1])
+           {
+           case 'd':
+           case 'i':
+           case 'o':
+           case 'u':
+           case 'x':
+           case 'X':
+           case 'c':
+             {
+               /* Short values are promoted to int, so just copy it
+                  as an int and trust the C library printf to cast it
+                  to the right width.  */
+               if (short_width)
+                 PRINT_TYPE (int);
+               else
+                 {
+                   switch (wide_width)
+                     {
+                     case 0:
+                       PRINT_TYPE (int);
+                       break;
+                     case 1:
+                       PRINT_TYPE (long);
+                       break;
+                     case 2:
+                     default:
+#if defined(__GNUC__) || defined(HAVE_LONG_LONG)
+                       PRINT_TYPE (long long);
+#else
+                       /* Fake it and hope for the best.  */
+                       PRINT_TYPE (long);
+#endif
+                       break;
+                     }
+                 }
+             }
+             break;
+           case 'f':
+           case 'e':
+           case 'E':
+           case 'g':
+           case 'G':
+             {
+               if (wide_width == 0)
+                 PRINT_TYPE (double);
+               else
+                 {
+#if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
+                   PRINT_TYPE (long double);
+#else
+                   /* Fake it and hope for the best.  */
+                   PRINT_TYPE (double);
+#endif
+                 }
+             }
+             break;
+           case 's':
+             PRINT_TYPE (char *);
+             break;
+           case 'p':
+             PRINT_TYPE (void *);
+             break;
+           case '%':
+             fputc ('%', stream);
+             result = 1;
+             break;
+           case 'A':
+             {
+               asection *sec = va_arg (ap, asection *);
+               bfd *abfd;
+               const char *group = NULL;
+               struct coff_comdat_info *ci;
+
+               if (sec == NULL)
+                 /* Invoking %A with a null section pointer is an
+                    internal error.  */
+                 abort ();
+               abfd = sec->owner;
+               if (abfd != NULL
+                   && bfd_get_flavour (abfd) == bfd_target_elf_flavour
+                   && elf_next_in_group (sec) != NULL
+                   && (sec->flags & SEC_GROUP) == 0)
+                 group = elf_group_name (sec);
+               else if (abfd != NULL
+                        && bfd_get_flavour (abfd) == bfd_target_coff_flavour
+                        && (ci = bfd_coff_get_comdat_section (sec->owner,
+                                                              sec)) != NULL)
+                 group = ci->name;
+               if (group != NULL)
+                 result = fprintf (stream, "%s[%s]", sec->name, group);
+               else
+                 result = fprintf (stream, "%s", sec->name);
+             }
+             break;
+           case 'B':
+             {
+               bfd *abfd = va_arg (ap, bfd *);
+
+               if (abfd == NULL)
+                 /* Invoking %B with a null bfd pointer is an
+                    internal error.  */
+                 abort ();
+               else if (abfd->my_archive
+                        && !bfd_is_thin_archive (abfd->my_archive))
+                 result = fprintf (stream, "%s(%s)",
+                                   abfd->my_archive->filename, abfd->filename);
+               else
+                 result = fprintf (stream, "%s", abfd->filename);
+             }
+             break;
+           default:
+             abort();
            }
        }
-      p = p + 2;
+      if (result == -1)
+       return -1;
+      total_printed += result;
     }
 
-  vfprintf (stderr, new_fmt, ap);
+  return total_printed;
+}
+
+/* This is the default routine to handle BFD error messages.
+   Like fprintf (stderr, ...), but also handles some extra format specifiers.
+
+   %A section name from section.  For group components, print group name too.
+   %B file name from bfd.  For archive components, prints archive too.  */
+
+static void
+error_handler_internal (const char *fmt, va_list ap)
+{
+  /* PR 4992: Don't interrupt output being sent to stdout.  */
+  fflush (stdout);
+
+  if (_bfd_error_program_name != NULL)
+    fprintf (stderr, "%s: ", _bfd_error_program_name);
+  else
+    fprintf (stderr, "BFD: ");
+
+  _doprnt (stderr, fmt, ap);
 
   /* On AIX, putc is implemented as a macro that triggers a -Wunused-value
      warning, so use the fputc function to avoid it.  */
index 3c892ef..b66ebe4 100644 (file)
@@ -1362,7 +1362,7 @@ coff_arm_relocate_section (bfd *output_bfd,
                              /* xgettext:c-format */
                              (_("%B(%s): warning: interworking not enabled.\n"
                                 "  first occurrence: %B: arm call to thumb"),
-                              h_sec->owner, input_bfd, name);
+                              h_sec->owner, name, input_bfd);
 
                          --my_offset;
                          myh->root.u.def.value = my_offset;
@@ -1453,7 +1453,7 @@ coff_arm_relocate_section (bfd *output_bfd,
                              (_("%B(%s): warning: interworking not enabled.\n"
                                 "  first occurrence: %B: thumb call to arm\n"
                                 "  consider relinking with --support-old-code enabled"),
-                              h_sec->owner, input_bfd, name);
+                              h_sec->owner, name, input_bfd);
 
                          -- my_offset;
                          myh->root.u.def.value = my_offset;
@@ -1744,7 +1744,7 @@ coff_arm_relocate_section (bfd *output_bfd,
          _bfd_error_handler
            /* xgettext:c-format */
            (_("%B: bad reloc address 0x%lx in section `%A'"),
-            input_bfd, input_section, (unsigned long) rel->r_vaddr);
+            input_bfd, (unsigned long) rel->r_vaddr, input_section);
          return FALSE;
        case bfd_reloc_overflow:
          {
@@ -2201,9 +2201,8 @@ coff_arm_merge_private_bfd_data (bfd * ibfd, struct bfd_link_info *info)
              _bfd_error_handler
                /* xgettext: c-format */
                (_("error: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"),
-                ibfd, obfd,
-                APCS_26_FLAG (ibfd) ? 26 : 32,
-                APCS_26_FLAG (obfd) ? 26 : 32
+                ibfd, APCS_26_FLAG (ibfd) ? 26 : 32,
+                obfd, APCS_26_FLAG (obfd) ? 26 : 32
                 );
 
              bfd_set_error (bfd_error_wrong_format);
index 4d4bcbc..3ede766 100644 (file)
@@ -480,7 +480,7 @@ coff_mcore_relocate_section (bfd * output_bfd,
            /* xgettext: c-format */
            (_("Warning: unsupported reloc %s <file %B, section %A>\n"
               "sym %ld (%s), r_vaddr %ld (%lx)"),
-            input_bfd, input_section, howto->name,
+            howto->name, input_bfd, input_section,
             rel->r_symndx, my_name, (long) rel->r_vaddr,
             (unsigned long) rel->r_vaddr);
          break;
index 7cd29ac..9dca30c 100644 (file)
@@ -1243,7 +1243,7 @@ coff_ppc_relocate_section (bfd *output_bfd,
              /* xgettext: c-format */
              (_("Warning: unsupported reloc %s <file %B, section %A>\n"
                 "sym %ld (%s), r_vaddr %ld (%lx)"),
-              input_bfd, input_section, howto->name,
+              howto->name, input_bfd, input_section,
               rel->r_symndx, my_name, (long) rel->r_vaddr,
               (unsigned long) rel->r_vaddr);
          }
index c3e20d9..ec1d1fd 100644 (file)
@@ -668,7 +668,7 @@ coff_tic80_relocate_section (bfd *output_bfd,
          _bfd_error_handler
            /* xgettext: c-format */
            (_("%B: bad reloc address 0x%lx in section `%A'"),
-            input_bfd, input_section, (unsigned long) rel->r_vaddr);
+            input_bfd, (unsigned long) rel->r_vaddr, input_section);
          return FALSE;
        case bfd_reloc_overflow:
          {
index 41cf77d..033b64e 100644 (file)
@@ -447,8 +447,9 @@ coff_link_add_symbols (bfd *abfd,
                                   || BTYPE (sym.n_type) == T_NULL)))
                        _bfd_error_handler
                          /* xgettext: c-format */
-                         (_("Warning: type of symbol `%s' changed from %d to %d in %B"),
-                          abfd, name, (*sym_hash)->type, sym.n_type);
+                         (_("Warning: type of symbol `%s' changed"
+                            " from %d to %d in %B"),
+                          name, (*sym_hash)->type, sym.n_type, abfd);
 
                      /* We don't want to change from a meaningful
                         base type to a null one, but if we know
@@ -3124,7 +3125,7 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd,
          _bfd_error_handler
            /* xgettext: c-format */
            (_("%B: bad reloc address 0x%lx in section `%A'"),
-            input_bfd, input_section, (unsigned long) rel->r_vaddr);
+            input_bfd, (unsigned long) rel->r_vaddr, input_section);
          return FALSE;
        case bfd_reloc_overflow:
          {
index 3f4f088..1570365 100644 (file)
@@ -306,7 +306,7 @@ elf_s390_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
          _bfd_error_handler
            /* xgettext:c-format */
            (_("Warning: %B uses vector %s ABI, %B uses %s ABI"),
-            ibfd, obfd, abi_str[in_attr->i], abi_str[out_attr->i]);
+            ibfd, abi_str[in_attr->i], obfd, abi_str[out_attr->i]);
        }
       if (in_attr->i > out_attr->i)
        out_attr->i = in_attr->i;
index 1f02d42..802a339 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -836,7 +836,7 @@ _bfd_elf_setup_sections (bfd *abfd)
                  _bfd_error_handler
                    /* xgettext:c-format */
                    (_("%B: sh_link [%d] in section `%A' is incorrect"),
-                    s->owner, s, elfsec);
+                    s->owner, elfsec, s);
                  result = FALSE;
                }
 
@@ -3213,7 +3213,7 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
       _bfd_error_handler
        /* xgettext:c-format */
        (_("%B: error: Alignment power %d of section `%A' is too big"),
-        abfd, asect, asect->alignment_power);
+        abfd, asect->alignment_power, asect);
       arg->failed = TRUE;
       return;
     }
index e04caef..e0ae923 100644 (file)
@@ -4092,7 +4092,7 @@ arm_type_of_stub (struct bfd_link_info *info,
                  _bfd_error_handler
                    (_("%B(%s): warning: interworking not enabled.\n"
                       "  first occurrence: %B: Thumb call to ARM"),
-                    sym_sec->owner, input_bfd, name);
+                    sym_sec->owner, name, input_bfd);
                }
 
              stub_type =
@@ -8810,7 +8810,7 @@ elf32_thumb_to_arm_stub (struct bfd_link_info * info,
          _bfd_error_handler
            (_("%B(%s): warning: interworking not enabled.\n"
               "  first occurrence: %B: Thumb call to ARM"),
-            sym_sec->owner, input_bfd, name);
+            sym_sec->owner, name, input_bfd);
 
          return FALSE;
        }
@@ -8900,7 +8900,7 @@ elf32_arm_create_thumb_stub (struct bfd_link_info * info,
          _bfd_error_handler
            (_("%B(%s): warning: interworking not enabled.\n"
               "  first occurrence: %B: arm call to thumb"),
-            sym_sec->owner, input_bfd, name);
+            sym_sec->owner, name, input_bfd);
        }
 
       --my_offset;
@@ -19697,9 +19697,8 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
     {
       _bfd_error_handler
        (_("error: Source object %B has EABI version %d, but target %B has EABI version %d"),
-        ibfd, obfd,
-        (in_flags & EF_ARM_EABIMASK) >> 24,
-        (out_flags & EF_ARM_EABIMASK) >> 24);
+        ibfd, (in_flags & EF_ARM_EABIMASK) >> 24,
+        obfd, (out_flags & EF_ARM_EABIMASK) >> 24);
       return FALSE;
     }
 
@@ -19713,9 +19712,8 @@ elf32_arm_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
        {
          _bfd_error_handler
            (_("error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
-            ibfd, obfd,
-            in_flags & EF_ARM_APCS_26 ? 26 : 32,
-            out_flags & EF_ARM_APCS_26 ? 26 : 32);
+            ibfd, in_flags & EF_ARM_APCS_26 ? 26 : 32,
+            obfd, out_flags & EF_ARM_APCS_26 ? 26 : 32);
          flags_compatible = FALSE;
        }
 
index 7f2723d..3e3aa16 100644 (file)
@@ -1569,8 +1569,8 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd,
        /* xgettext:c-format */
        (_("%B: TLS transition from %s to %s against `%s' at 0x%lx "
           "in section `%A' failed"),
-        abfd, sec, from->name, to->name, name,
-        (unsigned long) rel->r_offset);
+        abfd, from->name, to->name, name,
+        (unsigned long) rel->r_offset, sec);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -3836,7 +3836,7 @@ elf_i386_relocate_section (bfd *output_bfd,
          _bfd_error_handler
            /* xgettext:c-format */
            (_("%B: unrecognized relocation (0x%x) in section `%A'"),
-            input_bfd, input_section, r_type);
+            input_bfd, r_type, input_section);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
index 645a1ff..7ecf95f 100644 (file)
@@ -2983,9 +2983,9 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                      /* xgettext:c-format */
                      (_("%B: The target (%s) of an %s relocation is in the wrong section (%A)"),
                       input_bfd,
-                      sec,
                       sym_name,
-                      m32r_elf_howto_table[(int) r_type].name);
+                      m32r_elf_howto_table[(int) r_type].name,
+                      sec);
                    /*bfd_set_error (bfd_error_bad_value); ??? why? */
                    ret = FALSE;
                    continue;
index 43fcff5..8755280 100644 (file)
@@ -2445,9 +2445,8 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info)
       _bfd_error_handler
        /* xgettext:c-format */
        (_("error: %B uses %s instructions but %B uses %s"),
-        ibfd, first_input_bfd,
-        isa_type (in_attr[OFBA_MSPABI_Tag_ISA].i),
-        isa_type (out_attr[OFBA_MSPABI_Tag_ISA].i));
+        ibfd, isa_type (in_attr[OFBA_MSPABI_Tag_ISA].i),
+        first_input_bfd, isa_type (out_attr[OFBA_MSPABI_Tag_ISA].i));
       result = FALSE;
     }
 
@@ -2458,9 +2457,8 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info)
       _bfd_error_handler
        /* xgettext:c-format */
        (_("error: %B uses the %s code model whereas %B uses the %s code model"),
-        ibfd, first_input_bfd,
-        code_model (in_attr[OFBA_MSPABI_Tag_Code_Model].i),
-        code_model (out_attr[OFBA_MSPABI_Tag_Code_Model].i));
+        ibfd, code_model (in_attr[OFBA_MSPABI_Tag_Code_Model].i),
+        first_input_bfd, code_model (out_attr[OFBA_MSPABI_Tag_Code_Model].i));
       result = FALSE;
     }
 
@@ -2482,9 +2480,8 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info)
       _bfd_error_handler
        /* xgettext:c-format */
        (_("error: %B uses the %s data model whereas %B uses the %s data model"),
-        ibfd, first_input_bfd,
-        data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i),
-        data_model (out_attr[OFBA_MSPABI_Tag_Data_Model].i));
+        ibfd, data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i),
+        first_input_bfd, data_model (out_attr[OFBA_MSPABI_Tag_Data_Model].i));
       result = FALSE;
     }
 
@@ -2507,8 +2504,8 @@ elf32_msp430_merge_mspabi_attributes (bfd *ibfd, struct bfd_link_info *info)
       _bfd_error_handler
        /* xgettext:c-format */
        (_("error: %B uses the %s data model but %B only uses MSP430 instructions"),
-        ibfd, first_input_bfd,
-        data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i));
+        ibfd, data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i),
+        first_input_bfd);
       result = FALSE;
     }
 
index a8e7ef2..cbb026e 100644 (file)
@@ -1019,7 +1019,7 @@ needs_ovl_stub (struct elf_link_hash_entry *h,
              _bfd_error_handler
                /* xgettext:c-format */
                (_("warning: call to non-function symbol %s defined in %B"),
-                sym_sec->owner, sym_name);
+                sym_name, sym_sec->owner);
 
            }
        }
index 3e316d3..7c4dfb3 100644 (file)
@@ -584,8 +584,9 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."),
-                sec->owner, sec, (unsigned long) roff);
+               (_("%B: Can't relax br at 0x%lx in section `%A'."
+                  " Please use brl or indirect branch."),
+                sec->owner, (unsigned long) roff, sec);
              bfd_set_error (bfd_error_bad_value);
              goto error_return;
            }
@@ -3947,9 +3948,10 @@ elf64_ia64_relocate_section (bfd *output_bfd,
              case R_IA64_LTOFF_DTPREL22:
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."),
-                  input_bfd, input_section, howto->name, name,
-                  rel->r_offset);
+                 (_("%B: missing TLS section for relocation %s against `%s'"
+                    " at 0x%lx in section `%A'."),
+                  input_bfd, howto->name, name,
+                  rel->r_offset, input_section);
                break;
 
              case R_IA64_PCREL21B:
@@ -3963,9 +3965,10 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                       that the section is too big to relax.  */
                    _bfd_error_handler
                      /* xgettext:c-format */
-                     (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."),
-                      input_bfd, input_section, howto->name, name,
-                      rel->r_offset, input_section->size);
+                     (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section"
+                        " `%A' with size 0x%lx (> 0x1000000)."),
+                      input_bfd, howto->name, name, rel->r_offset,
+                      input_section, input_section->size);
                    break;
                  }
                /* Fall through.  */
@@ -5135,15 +5138,15 @@ error_free_dyn:
                      /* xgettext:c-format */
                      (_("Warning: alignment %u of common symbol `%s' in %B"
                         " is greater than the alignment (%u) of its section %A"),
-                      common_bfd, h->root.u.def.section,
-                      1 << common_align, name, 1 << normal_align);
+                      1 << common_align, name, common_bfd,
+                      1 << normal_align, h->root.u.def.section);
                  else
                    _bfd_error_handler
                      /* xgettext:c-format */
                      (_("Warning: alignment %u of symbol `%s' in %B"
                         " is smaller than %u in %B"),
-                      normal_bfd, common_bfd,
-                      1 << normal_align, name, 1 << common_align);
+                      1 << normal_align, name, normal_bfd,
+                      1 << common_align, common_bfd);
                }
            }
 
@@ -5158,9 +5161,8 @@ error_free_dyn:
                  /* xgettext:c-format */
                  (_("Warning: size of symbol `%s' changed"
                     " from %lu in %B to %lu in %B"),
-                  old_bfd, abfd,
-                  name, (unsigned long) h->size,
-                  (unsigned long) isym->st_size);
+                  name, (unsigned long) h->size, old_bfd,
+                  (unsigned long) isym->st_size, abfd);
 
              h->size = isym->st_size;
            }
@@ -5186,7 +5188,7 @@ error_free_dyn:
                      /* xgettext:c-format */
                      (_("Warning: type of symbol `%s' changed"
                         " from %d to %d in %B"),
-                      abfd, name, h->type, type);
+                      name, h->type, type, abfd);
 
                  h->type = type;
                }
index 7425dbe..9456b59 100644 (file)
@@ -466,10 +466,10 @@ elf64_sparc_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
        {
          _bfd_error_handler
            /* xgettext:c-format */
-            (_("Register %%g%d used incompatibly: %s in %B, previously %s in %B"),
-             abfd, p->abfd, (int) sym->st_value,
-             **namep ? *namep : "#scratch",
-             *p->name ? p->name : "#scratch");
+           (_("Register %%g%d used incompatibly: %s in %B,"
+              " previously %s in %B"),
+            (int) sym->st_value, **namep ? *namep : "#scratch", abfd,
+            *p->name ? p->name : "#scratch", p->abfd);
          return FALSE;
        }
 
@@ -490,8 +490,9 @@ elf64_sparc_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
                    type = 0;
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("Symbol `%s' has differing types: REGISTER in %B, previously %s in %B"),
-                    abfd, p->abfd, *namep, stt_types[type]);
+                   (_("Symbol `%s' has differing types: REGISTER in %B,"
+                      " previously %s in %B"),
+                    *namep, abfd, stt_types[type], p->abfd);
                  return FALSE;
                }
 
@@ -536,8 +537,9 @@ elf64_sparc_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
              type = 0;
            _bfd_error_handler
              /* xgettext:c-format */
-             (_("Symbol `%s' has differing types: %s in %B, previously REGISTER in %B"),
-              abfd, p->abfd, *namep, stt_types[type]);
+             (_("Symbol `%s' has differing types: %s in %B,"
+                " previously REGISTER in %B"),
+              *namep, stt_types[type], abfd, p->abfd);
            return FALSE;
          }
     }
index 5d3a653..dbbdf89 100644 (file)
@@ -1702,8 +1702,8 @@ elf_x86_64_tls_transition (struct bfd_link_info *info, bfd *abfd,
        /* xgettext:c-format */
        (_("%B: TLS transition from %s to %s against `%s' at 0x%lx "
           "in section `%A' failed"),
-        abfd, sec, from->name, to->name, name,
-        (unsigned long) rel->r_offset);
+        abfd, from->name, to->name, name,
+        (unsigned long) rel->r_offset, sec);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -4284,7 +4284,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
          _bfd_error_handler
            /* xgettext:c-format */
            (_("%B: unrecognized relocation (0x%x) in section `%A'"),
-            input_bfd, input_section, r_type);
+            input_bfd, r_type, input_section);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
@@ -5065,18 +5065,16 @@ direct:
                              (_("%B: addend -0x%x in relocation %s against "
                                 "symbol `%s' at 0x%lx in section `%A' is "
                                 "out of range"),
-                              input_bfd, input_section, addend,
-                              howto->name, name,
-                              (unsigned long) rel->r_offset);
+                              input_bfd, addend, howto->name, name,
+                              (unsigned long) rel->r_offset, input_section);
                          else
                            _bfd_error_handler
                              /* xgettext:c-format */
                              (_("%B: addend 0x%x in relocation %s against "
                                 "symbol `%s' at 0x%lx in section `%A' is "
                                 "out of range"),
-                              input_bfd, input_section, addend,
-                              howto->name, name,
-                              (unsigned long) rel->r_offset);
+                              input_bfd, addend, howto->name, name,
+                              (unsigned long) rel->r_offset, input_section);
                          bfd_set_error (bfd_error_bad_value);
                          return FALSE;
                        }
index c00d712..ae8fe24 100644 (file)
@@ -1298,25 +1298,25 @@ _bfd_elf_merge_symbol (bfd *abfd,
          /* xgettext:c-format */
          (_("%s: TLS definition in %B section %A "
             "mismatches non-TLS definition in %B section %A"),
-          tbfd, tsec, ntbfd, ntsec, h->root.root.string);
+          h->root.root.string, tbfd, tsec, ntbfd, ntsec);
       else if (!tdef && !ntdef)
        _bfd_error_handler
          /* xgettext:c-format */
          (_("%s: TLS reference in %B "
             "mismatches non-TLS reference in %B"),
-          tbfd, ntbfd, h->root.root.string);
+          h->root.root.string, tbfd, ntbfd);
       else if (tdef)
        _bfd_error_handler
          /* xgettext:c-format */
          (_("%s: TLS definition in %B section %A "
             "mismatches non-TLS reference in %B"),
-          tbfd, tsec, ntbfd, h->root.root.string);
+          h->root.root.string, tbfd, tsec, ntbfd);
       else
        _bfd_error_handler
          /* xgettext:c-format */
          (_("%s: TLS reference in %B "
             "mismatches non-TLS definition in %B section %A"),
-          tbfd, ntbfd, ntsec, h->root.root.string);
+          h->root.root.string, tbfd, ntbfd, ntsec);
 
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
@@ -2359,8 +2359,8 @@ elf_link_read_relocs_from_section (bfd *abfd,
                /* xgettext:c-format */
                (_("%B: bad reloc symbol index (0x%lx >= 0x%lx)"
                   " for offset 0x%lx in section `%A'"),
-                abfd, sec,
-                (unsigned long) r_symndx, (unsigned long) nsyms, irela->r_offset);
+                abfd, (unsigned long) r_symndx, (unsigned long) nsyms,
+                irela->r_offset, sec);
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -2369,10 +2369,11 @@ elf_link_read_relocs_from_section (bfd *abfd,
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: non-zero symbol index (0x%lx) for offset 0x%lx in section `%A'"
+           (_("%B: non-zero symbol index (0x%lx)"
+              " for offset 0x%lx in section `%A'"
               " when the object file has no symbol table"),
-            abfd, sec,
-            (unsigned long) r_symndx, (unsigned long) nsyms, irela->r_offset);
+            abfd, (unsigned long) r_symndx, (unsigned long) nsyms,
+            irela->r_offset, sec);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
@@ -4673,15 +4674,15 @@ error_free_dyn:
                      /* xgettext:c-format */
                      (_("Warning: alignment %u of common symbol `%s' in %B is"
                         " greater than the alignment (%u) of its section %A"),
-                      common_bfd, h->root.u.def.section,
-                      1 << common_align, name, 1 << normal_align);
+                      1 << common_align, name, common_bfd,
+                      1 << normal_align, h->root.u.def.section);
                  else
                    _bfd_error_handler
                      /* xgettext:c-format */
                      (_("Warning: alignment %u of symbol `%s' in %B"
                         " is smaller than %u in %B"),
-                      normal_bfd, common_bfd,
-                      1 << normal_align, name, 1 << common_align);
+                      1 << normal_align, name, normal_bfd,
+                      1 << common_align, common_bfd);
                }
            }
 
@@ -4697,9 +4698,8 @@ error_free_dyn:
                  /* xgettext:c-format */
                  (_("Warning: size of symbol `%s' changed"
                     " from %lu in %B to %lu in %B"),
-                  old_bfd, abfd,
-                  name, (unsigned long) h->size,
-                  (unsigned long) isym->st_size);
+                  name, (unsigned long) h->size, old_bfd,
+                  (unsigned long) isym->st_size, abfd);
 
              h->size = isym->st_size;
            }
@@ -4733,7 +4733,7 @@ error_free_dyn:
                    _bfd_error_handler
                      (_("Warning: type of symbol `%s' changed"
                         " from %d to %d in %B"),
-                      abfd, name, h->type, type);
+                      name, h->type, type, abfd);
 
                  h->type = type;
                }
@@ -9456,8 +9456,8 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
       def_bfd = flinfo->output_bfd;
       if (hi->root.u.def.section != bfd_abs_section_ptr)
        def_bfd = hi->root.u.def.section->owner;
-      _bfd_error_handler (msg, flinfo->output_bfd, def_bfd,
-                         h->root.root.string);
+      _bfd_error_handler (msg, flinfo->output_bfd,
+                         h->root.root.string, def_bfd);
       bfd_set_error (bfd_error_bad_value);
       eoinfo->failed = TRUE;
       return FALSE;
@@ -10384,7 +10384,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
                        /* xgettext:c-format */
                        (_("error: %B contains a reloc (0x%s) for section %A "
                           "that references a non-existent global symbol"),
-                        input_bfd, o, buffer);
+                        input_bfd, buffer, o);
                      bfd_set_error (bfd_error_bad_value);
                      return FALSE;
                    }
@@ -12982,8 +12982,8 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
 
          if (info->print_gc_sections && o->size != 0)
            /* xgettext:c-format */
-           _bfd_error_handler (_("Removing unused section '%s' in file '%B'"),
-                               sub, o->name);
+           _bfd_error_handler (_("Removing unused section '%A' in file '%B'"),
+                               o, sub);
 
          /* But we also have to update some of the relocation
             info we collected before.  */
index 710e2c3..9976638 100644 (file)
@@ -6109,7 +6109,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
          /* xgettext:c-format */
          _bfd_error_handler
            (_("%B: unrecognized relocation (0x%x) in section `%A'"),
-            input_bfd, input_section, r_type);
+            input_bfd, r_type, input_section);
          return FALSE;
        }
       bfd_r_type = elfNN_aarch64_bfd_reloc_from_howto (howto);
index 6f92b34..3c27f5d 100644 (file)
@@ -617,8 +617,9 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."),
-                sec->owner, sec, (unsigned long) roff);
+               (_("%B: Can't relax br at 0x%lx in section `%A'."
+                  " Please use brl or indirect branch."),
+                sec->owner, (unsigned long) roff, sec);
              bfd_set_error (bfd_error_bad_value);
              goto error_return;
            }
@@ -4474,9 +4475,10 @@ missing_tls_sec:
              case R_IA64_LTOFF_DTPREL22:
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."),
-                  input_bfd, input_section, howto->name, name,
-                  rel->r_offset);
+                 (_("%B: missing TLS section for relocation %s against `%s'"
+                    " at 0x%lx in section `%A'."),
+                  input_bfd, howto->name, name,
+                  rel->r_offset, input_section);
                break;
 
              case R_IA64_PCREL21B:
@@ -4490,9 +4492,10 @@ missing_tls_sec:
                       that the section is too big to relax.  */
                    _bfd_error_handler
                      /* xgettext:c-format */
-                     (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."),
-                      input_bfd, input_section, howto->name, name,
-                      rel->r_offset, input_section->size);
+                     (_("%B: Can't relax br (%s) to `%s' at 0x%lx"
+                        " in section `%A' with size 0x%lx (> 0x1000000)."),
+                      input_bfd, howto->name, name, rel->r_offset,
+                      input_section, input_section->size);
                    break;
                  }
                /* Fall through.  */
index 901ddc1..4efa513 100644 (file)
@@ -10132,9 +10132,10 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                                                 sec);
                      _bfd_error_handler
                        /* xgettext:c-format */
-                       (_("%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"),
-                        input_bfd, input_section, name, howto->name,
-                        rel->r_offset);
+                       (_("%B: Can't find matching LO16 reloc against `%s'"
+                          " for %s at 0x%lx in section `%A'"),
+                        input_bfd, name,
+                        howto->name, rel->r_offset, input_section);
                    }
                }
              else
@@ -10679,8 +10680,8 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
                       "beyond the range of ADDIUPC"),
                     output_bfd,
                     htab->root.sgotplt->output_section,
-                    htab->root.splt->output_section,
-                    (long) gotpc_offset);
+                    (long) gotpc_offset,
+                    htab->root.splt->output_section);
                  bfd_set_error (bfd_error_no_error);
                  return FALSE;
                }
@@ -11246,8 +11247,8 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
            (_("%B: `%A' offset of %ld from `%A' beyond the range of ADDIUPC"),
             output_bfd,
             htab->root.sgotplt->output_section,
-            htab->root.splt->output_section,
-            (long) gotpc_offset);
+            (long) gotpc_offset,
+            htab->root.splt->output_section);
          bfd_set_error (bfd_error_no_error);
          return FALSE;
        }
@@ -15197,19 +15198,19 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
            _bfd_error_handler
              (_("Warning: %B uses unknown floating point ABI %d "
                 "(set by %B), %B uses unknown floating point ABI %d"),
-              obfd, abi_fp_bfd, ibfd, out_fp, in_fp);
+              obfd, out_fp, abi_fp_bfd, ibfd, in_fp);
          else if (!out_string)
            _bfd_error_handler
              /* xgettext:c-format */
              (_("Warning: %B uses unknown floating point ABI %d "
                 "(set by %B), %B uses %s"),
-              obfd, abi_fp_bfd, ibfd, out_fp, in_string);
+              obfd, out_fp, abi_fp_bfd, ibfd, in_string);
          else if (!in_string)
            _bfd_error_handler
              /* xgettext:c-format */
              (_("Warning: %B uses %s (set by %B), "
                 "%B uses unknown floating point ABI %d"),
-              obfd, abi_fp_bfd, ibfd, out_string, in_fp);
+              obfd, out_string, abi_fp_bfd, ibfd, in_fp);
          else
            {
              /* If one of the bfds is soft-float, the other must be
@@ -15222,7 +15223,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
              _bfd_error_handler
                /* xgettext:c-format */
                (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                obfd, abi_fp_bfd, ibfd, out_string, in_string);
+                obfd, out_string, abi_fp_bfd, ibfd, in_string);
            }
        }
     }
@@ -15242,8 +15243,8 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
              /* xgettext:c-format */
              (_("Warning: %B uses %s (set by %B), "
                 "%B uses unknown MSA ABI %d"),
-              obfd, abi_msa_bfd, ibfd,
-              "-mmsa", in_attr[Tag_GNU_MIPS_ABI_MSA].i);
+              obfd, "-mmsa", abi_msa_bfd,
+              ibfd, in_attr[Tag_GNU_MIPS_ABI_MSA].i);
            break;
 
          default:
@@ -15254,8 +15255,8 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
                  /* xgettext:c-format */
                  (_("Warning: %B uses unknown MSA ABI %d "
                     "(set by %B), %B uses %s"),
-                    obfd, abi_msa_bfd, ibfd,
-                    out_attr[Tag_GNU_MIPS_ABI_MSA].i, "-mmsa");
+                    obfd, out_attr[Tag_GNU_MIPS_ABI_MSA].i,
+                  abi_msa_bfd, ibfd, "-mmsa");
                  break;
 
              default:
@@ -15263,9 +15264,8 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
                  /* xgettext:c-format */
                  (_("Warning: %B uses unknown MSA ABI %d "
                     "(set by %B), %B uses unknown MSA ABI %d"),
-                  obfd, abi_msa_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_MSA].i,
-                  in_attr[Tag_GNU_MIPS_ABI_MSA].i);
+                  obfd, out_attr[Tag_GNU_MIPS_ABI_MSA].i,
+                  abi_msa_bfd, ibfd, in_attr[Tag_GNU_MIPS_ABI_MSA].i);
                break;
              }
          }