* bfd.c (bfd_perror): Flush stdout before and stderr after printing
authorAlan Modra <amodra@gmail.com>
Fri, 14 Jan 2011 12:35:56 +0000 (12:35 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 14 Jan 2011 12:35:56 +0000 (12:35 +0000)
error.
(_bfd_default_error_handler): Likewise.
* elf.c (print_segment_map): Likewise.
* libbfd.c (warn_deprecated): Likewise.
* som.c (som_sizeof_headers): No need to do so here.
* coff-i860.c: Replace use of printf for error messages with
_bfd_error_handler.
* coff-ppc.c: Likewise.
* coff-sh.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-dlx.c: Likewise.
* elf32-mep.c: Likewise.
* elf32-v850.c: Likewise.
* mach-o.c: Likewise.
* pef.c: Likewise.

14 files changed:
bfd/ChangeLog
bfd/bfd.c
bfd/coff-i860.c
bfd/coff-ppc.c
bfd/coff-sh.c
bfd/elf.c
bfd/elf32-bfin.c
bfd/elf32-dlx.c
bfd/elf32-mep.c
bfd/elf32-v850.c
bfd/libbfd.c
bfd/mach-o.c
bfd/pef.c
bfd/som.c

index 326b326..f14a7cb 100644 (file)
@@ -1,3 +1,22 @@
+2011-01-14  Alan Modra  <amodra@gmail.com>
+
+       * bfd.c (bfd_perror): Flush stdout before and stderr after printing
+       error.
+       (_bfd_default_error_handler): Likewise.
+       * elf.c (print_segment_map): Likewise.
+       * libbfd.c (warn_deprecated): Likewise.
+       * som.c (som_sizeof_headers): No need to do so here.
+       * coff-i860.c: Replace use of printf for error messages with
+       _bfd_error_handler.
+       * coff-ppc.c: Likewise.
+       * coff-sh.c: Likewise.
+       * elf32-bfin.c: Likewise.
+       * elf32-dlx.c: Likewise.
+       * elf32-mep.c: Likewise.
+       * elf32-v850.c: Likewise.
+       * mach-o.c: Likewise.
+       * pef.c: Likewise.
+
 2011-01-13  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf64-x86-64.c (elf_x86_64_link_hash_table): Remove
index a9ce7cc..77582ec 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1,6 +1,6 @@
 /* Generic BFD library interface and support routines.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -523,10 +523,12 @@ DESCRIPTION
 void
 bfd_perror (const char *message)
 {
+  fflush (stdout);
   if (message == NULL || *message == '\0')
     fprintf (stderr, "%s\n", bfd_errmsg (bfd_get_error ()));
   else
     fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_get_error ()));
+  fflush (stderr);
 }
 
 /*
@@ -723,6 +725,7 @@ _bfd_default_error_handler (const char *fmt, ...)
   va_end (ap);
 
   putc ('\n', stderr);
+  fflush (stderr);
 }
 
 /* This is a function pointer to the routine which should handle BFD
index b7ada16..d50b070 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel i860 COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2007, 2008, 2010  Free Software Foundation, Inc.
+   2003, 2004, 2005, 2007, 2008, 2010, 2011  Free Software Foundation, Inc.
    Created mostly by substituting "860" for "386" in coff-i386.c
    Harry Dolan <dolan@ssd.intel.com>, October 1995
 
@@ -144,7 +144,7 @@ coff_i860_reloc_nyi (bfd *abfd ATTRIBUTE_UNUSED,
                     char **error_message ATTRIBUTE_UNUSED)
 {
   reloc_howto_type *howto = reloc_entry->howto;
-  fprintf (stderr, _("Relocation `%s' not yet implemented\n"), howto->name);
+  (*_bfd_error_handler) (_("relocation `%s' not yet implemented"), howto->name);
   return bfd_reloc_notsupported;
 }
 
index 06eed24..69e10d8 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila (krk@cygnus.com)
@@ -1843,10 +1843,9 @@ ppc_coff_rtype2howto (relent, internal)
        howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16;
       break;
     default:
-      fprintf (stderr,
-             _("Warning: Unsupported reloc %s [%d] used -- it may not work.\n"),
-             ppc_coff_howto_table[r_type].name,
-             r_type);
+      (*_bfd_error_handler) (_("warning: unsupported reloc %s [%d] used -- it may not work"),
+                            ppc_coff_howto_table[r_type].name,
+                            r_type);
       howto = ppc_coff_howto_table + r_type;
       break;
     }
@@ -1916,10 +1915,9 @@ coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
       howto = ppc_coff_howto_table + r_type;
       break;
     default:
-      fprintf (stderr,
-             _("Warning: Unsupported reloc %s [%d] used -- it may not work.\n"),
-             ppc_coff_howto_table[r_type].name,
-             r_type);
+      (*_bfd_error_handler) (_("warning: unsupported reloc %s [%d] used -- it may not work"),
+                            ppc_coff_howto_table[r_type].name,
+                            r_type);
       howto = ppc_coff_howto_table + r_type;
       break;
     }
index 28ac0ab..b77af7c 100644 (file)
@@ -1,6 +1,7 @@
 /* BFD back-end for Renesas Super-H COFF binaries.
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
+   Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    Written by Steve Chamberlain, <sac@cygnus.com>.
    Relaxing code written by Ian Lance Taylor, <ian@cygnus.com>.
@@ -517,7 +518,7 @@ sh_coff_reloc_type_lookup (abfd, code)
     if (sh_reloc_map[i].bfd_reloc_val == code)
       return &sh_coff_howtos[(int) sh_reloc_map[i].shcoff_reloc_val];
 
-  fprintf (stderr, "SH Error: unknown reloc type %d\n", code);
+  (*_bfd_error_handler) (_("SH Error: unknown reloc type %d"), code);
   return NULL;
 }
 
index de0ab61..257cc8c 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,7 +1,7 @@
 /* ELF executable support for BFD.
 
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -4280,10 +4280,12 @@ print_segment_map (const struct elf_segment_map *m)
                  (unsigned int) m->p_type);
       pt = buf;
     }
+  fflush (stdout);
   fprintf (stderr, "%s:", pt);
   for (j = 0; j < m->count; j++)
     fprintf (stderr, " %s", m->sections [j]->name);
   putc ('\n',stderr);
+  fflush (stderr);
 }
 
 static bfd_boolean
index 56af244..8aba7ed 100644 (file)
@@ -1,5 +1,5 @@
 /* ADI Blackfin BFD support for 32-bit ELF.
-   Copyright 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -104,7 +104,7 @@ bfin_pcrel24_reloc (bfd *abfd,
   /* if rightshift is 1 and the number odd, return error.  */
   if (howto->rightshift && (relocation & 0x01))
     {
-      fprintf(stderr, "relocation should be even number\n");
+      (*_bfd_error_handler) (_("relocation should be even number"));
       return bfd_reloc_overflow;
     }
 
@@ -360,7 +360,7 @@ bfin_bfd_reloc (bfd *abfd,
   /* If rightshift is 1 and the number odd, return error.  */
   if (howto->rightshift && (relocation & 0x01))
     {
-      fprintf(stderr, "relocation should be even number\n");
+      (*_bfd_error_handler) (_("relocation should be even number"));
       return bfd_reloc_overflow;
     }
 
@@ -5276,7 +5276,8 @@ bfin_finish_dynamic_symbol (bfd * output_bfd,
          && (info->symbolic
              || h->dynindx == -1 || h->forced_local) && h->def_regular)
        {
-         fprintf(stderr, "*** check this relocation %s\n", __FUNCTION__);
+         (*_bfd_error_handler) (_("*** check this relocation %s"),
+                                __FUNCTION__);
          rela.r_info = ELF32_R_INFO (0, R_BFIN_PCREL24);
          rela.r_addend = bfd_get_signed_32 (output_bfd,
                                             (sgot->contents
index 6b96ac9..29b8910 100644 (file)
@@ -1,5 +1,5 @@
 /* DLX specific support for 32-bit ELF
-   Copyright 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2011
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -139,9 +139,8 @@ elf32_dlx_relocate16 (bfd *abfd,
   /* Can not support a long jump to sections other then .text.  */
   if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
     {
-      fprintf (stderr,
-              "BFD Link Error: branch (PC rel16) to section (%s) not supported\n",
-              symbol->section->output_section->name);
+      (*_bfd_error_handler) (_("BFD Link Error: branch (PC rel16) to section (%s) not supported"),
+                            symbol->section->output_section->name);
       return bfd_reloc_undefined;
     }
 
@@ -202,9 +201,8 @@ elf32_dlx_relocate26 (bfd *abfd,
   /* Can not support a long jump to sections other then .text   */
   if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
     {
-      fprintf (stderr,
-              "BFD Link Error: jump (PC rel26) to section (%s) not supported\n",
-              symbol->section->output_section->name);
+      (*_bfd_error_handler) (_("BFD Link Error: jump (PC rel26) to section (%s) not supported"),
+                            symbol->section->output_section->name);
       return bfd_reloc_undefined;
     }
 
index a6afcb5..b688d67 100644 (file)
@@ -1,6 +1,6 @@
 /* MeP-specific support for 32-bit ELF.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+   2010, 2011  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -154,13 +154,14 @@ mep_reloc_type_lookup
 
     default:
       /* Pacify gcc -Wall.  */
-      fprintf (stderr, "mep: no reloc for code %d\n", code);
+      (*_bfd_error_handler) (_("mep: no reloc for code %d"), code);
       return NULL;
     }
 
   if (mep_elf_howto_table[type].type != type)
     {
-      fprintf (stderr, "MeP: howto %d has type %d\n", type, mep_elf_howto_table[type].type);
+      (*_bfd_error_handler) (_("MeP: howto %d has type %d"),
+                            type, mep_elf_howto_table[type].type);
       abort ();
     }
 
index 29b2311..9e6f77d 100644 (file)
@@ -1,6 +1,6 @@
 /* V850-specific support for 32-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -480,7 +480,7 @@ v850_elf_perform_lo16_relocation (bfd *abfd, unsigned long *insn,
        }
       else
        {
-         fprintf (stderr, _("FAILED to find previous HI16 reloc\n"));
+         (*_bfd_error_handler) (_("FAILED to find previous HI16 reloc"));
          return FALSE;
        }
     }
index a66d9c6..8b24378 100644 (file)
@@ -1,6 +1,6 @@
 /* Assorted BFD support routines, only used internally.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -1021,6 +1021,7 @@ warn_deprecated (const char *what,
 
   if (~(size_t) func & ~mask)
     {
+      fflush (stdout);
       /* Note: separate sentences in order to allow
         for translation into other languages.  */
       if (func)
@@ -1028,6 +1029,7 @@ warn_deprecated (const char *what,
                 what, file, line, func);
       else
        fprintf (stderr, _("Deprecated %s called\n"), what);
+      fflush (stderr);
       mask |= ~(size_t) func;
     }
 }
index a02030e..0c0d1ac 100644 (file)
@@ -1,6 +1,6 @@
 /* Mach-O support for BFD.
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010
+   2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -378,8 +378,7 @@ bfd_mach_o_canonicalize_symtab (bfd *abfd, asymbol **alocation)
 
   if (bfd_mach_o_read_symtab_symbols (abfd) != 0)
     {
-      fprintf (stderr,
-               "bfd_mach_o_canonicalize_symtab: unable to load symbols\n");
+      (*_bfd_error_handler) (_("bfd_mach_o_canonicalize_symtab: unable to load symbols"));
       return 0;
     }
 
@@ -1251,9 +1250,8 @@ bfd_mach_o_write_contents (bfd *abfd)
        case BFD_MACH_O_LC_SUB_FRAMEWORK:
          break;
        default:
-         fprintf (stderr,
-                  "unable to write unknown load command 0x%lx\n",
-                  (unsigned long) cur->type);
+         (*_bfd_error_handler) (_("unable to write unknown load command 0x%lx"),
+                                (unsigned long) cur->type);
          return FALSE;
        }
     }
@@ -1653,8 +1651,8 @@ bfd_mach_o_read_symtab_symbol (bfd *abfd,
   if (bfd_seek (abfd, symoff, SEEK_SET) != 0
       || bfd_bread ((void *) buf, symwidth, abfd) != symwidth)
     {
-      fprintf (stderr, "bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu\n",
-              symwidth, (unsigned long) symoff);
+      (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu"),
+                            symwidth, (unsigned long) symoff);
       return -1;
     }
 
@@ -1670,8 +1668,9 @@ bfd_mach_o_read_symtab_symbol (bfd *abfd,
 
   if (stroff >= sym->strsize)
     {
-      fprintf (stderr, "bfd_mach_o_read_symtab_symbol: symbol name out of range (%lu >= %lu)\n",
-              (unsigned long) stroff, (unsigned long) sym->strsize);
+      (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: symbol name out of range (%lu >= %lu)"),
+                            (unsigned long) stroff,
+                            (unsigned long) sym->strsize);
       return -1;
     }
 
@@ -1754,23 +1753,23 @@ bfd_mach_o_read_symtab_symbol (bfd *abfd,
              /* Mach-O uses 0 to mean "no section"; not an error.  */
              if (section != 0)
                {
-                 fprintf (stderr, "bfd_mach_o_read_symtab_symbol: "
-                          "symbol \"%s\" specified invalid section %d (max %lu): setting to undefined\n",
-                          s->symbol.name, section, mdata->nsects);
+                 (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
+                                          "symbol \"%s\" specified invalid section %d (max %lu): setting to undefined"),
+                                        s->symbol.name, section, mdata->nsects);
                }
              s->symbol.section = bfd_und_section_ptr;
            }
          break;
        case BFD_MACH_O_N_INDR:
-         fprintf (stderr, "bfd_mach_o_read_symtab_symbol: "
-                  "symbol \"%s\" is unsupported 'indirect' reference: setting to undefined\n",
-                  s->symbol.name);
+         (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
+                                  "symbol \"%s\" is unsupported 'indirect' reference: setting to undefined"),
+                                s->symbol.name);
          s->symbol.section = bfd_und_section_ptr;
          break;
        default:
-         fprintf (stderr, "bfd_mach_o_read_symtab_symbol: "
-                  "symbol \"%s\" specified invalid type field 0x%x: setting to undefined\n",
-                  s->symbol.name, symtype);
+         (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
+                                  "symbol \"%s\" specified invalid type field 0x%x: setting to undefined"),
+                                s->symbol.name, symtype);
          s->symbol.section = bfd_und_section_ptr;
          break;
        }
@@ -1838,7 +1837,7 @@ bfd_mach_o_read_symtab_symbols (bfd *abfd)
 
   if (sym->symbols == NULL)
     {
-      fprintf (stderr, "bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols\n");
+      (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols"));
       return -1;
     }
 
@@ -1872,8 +1871,8 @@ bfd_mach_o_read_dysymtab_symbol (bfd *abfd,
   if (bfd_seek (abfd, isymoff, SEEK_SET) != 0
       || bfd_bread ((void *) buf, 4, abfd) != 4)
     {
-      fprintf (stderr, "bfd_mach_o_read_dysymtab_symbol: unable to read %lu bytes at %lu\n",
-              (unsigned long) 4, isymoff);
+      (*_bfd_error_handler) (_("bfd_mach_o_read_dysymtab_symbol: unable to read %lu bytes at %lu"),
+                              (unsigned long) 4, isymoff);
       return -1;
     }
   sym_index = bfd_h_get_32 (abfd, buf);
@@ -2554,8 +2553,8 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command)
        return -1;
       break;
     default:
-      fprintf (stderr, "unable to read unknown load command 0x%lx\n",
-              (unsigned long) command->type);
+      (*_bfd_error_handler) (_("unable to read unknown load command 0x%lx"),
+                            (unsigned long) command->type);
       break;
     }
 
@@ -2734,8 +2733,8 @@ bfd_mach_o_scan (bfd *abfd,
                                   &cputype, &cpusubtype);
   if (cputype == bfd_arch_unknown)
     {
-      fprintf (stderr, "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx\n",
-              header->cputype, header->cpusubtype);
+      (*_bfd_error_handler) (_("bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx"),
+                            header->cputype, header->cpusubtype);
       return -1;
     }
 
@@ -2830,8 +2829,8 @@ bfd_mach_o_header_p (bfd *abfd,
   if (! (header.byteorder == BFD_ENDIAN_BIG
         || header.byteorder == BFD_ENDIAN_LITTLE))
     {
-      fprintf (stderr, "unknown header byte-order value 0x%lx\n",
-              (unsigned long) header.byteorder);
+      (*_bfd_error_handler) (_("unknown header byte-order value 0x%lx"),
+                            (unsigned long) header.byteorder);
       goto wrong;
     }
 
index 788388c..dcfda05 100644 (file)
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -1,6 +1,6 @@
 /* PEF support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009, 2011  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -516,8 +516,8 @@ bfd_pef_scan (abfd, header, mdata)
   bfd_pef_convert_architecture (header->architecture, &cputype, &cpusubtype);
   if (cputype == bfd_arch_unknown)
     {
-      fprintf (stderr, "bfd_pef_scan: unknown architecture 0x%lx\n",
-              header->architecture);
+      (*_bfd_error_handler) (_("bfd_pef_scan: unknown architecture 0x%lx"),
+                              header->architecture);
       return -1;
     }
   bfd_set_arch_mach (abfd, cputype, cpusubtype);
index a46c35a..a18c869 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1,6 +1,6 @@
 /* bfd back-end for HP PA-RISC SOM objects.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
@@ -5774,7 +5774,6 @@ som_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
                    struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   (*_bfd_error_handler) (_("som_sizeof_headers unimplemented"));
-  fflush (stderr);
   abort ();
   return 0;
 }