diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2007-08-30 10:19:03 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@codesourcery.com> | 2007-08-30 10:19:03 +0000 |
commit | 2db6cde7362caa130c6f9d92a1d50f742d08c3d3 (patch) | |
tree | 24686122ed4e888fd967b26f9439fa8d4676d915 /binutils/bucomm.c | |
parent | 876d4bfa30530cfcddc152a1ae47f8045d80fd47 (diff) | |
download | gdb-2db6cde7362caa130c6f9d92a1d50f742d08c3d3.zip gdb-2db6cde7362caa130c6f9d92a1d50f742d08c3d3.tar.gz gdb-2db6cde7362caa130c6f9d92a1d50f742d08c3d3.tar.bz2 |
* bucomm.c (bfd_nonfatal_message): New.
* bucomm.h (bfd_nonfatal_message): Declare.
* objcopy.c (RETURN_NONFATAL): Take BFD not NAME, use
bfd_nonfatal_message.
(copy_unknown_object): Adjust bfd_nonfatal and RETURN_NONFATAL
calls, or replace with bfd_nonfatal_message calls as appropriate.
(copy_object, copy_archive, copy_file, setup_section,
copy_section, write_debugging_info): Likewise.
Diffstat (limited to 'binutils/bucomm.c')
-rw-r--r-- | binutils/bucomm.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/binutils/bucomm.c b/binutils/bucomm.c index 2f3ac07..26cb09e 100644 --- a/binutils/bucomm.c +++ b/binutils/bucomm.c @@ -60,6 +60,52 @@ bfd_nonfatal (const char *string) fprintf (stderr, "%s: %s\n", program_name, errmsg); } +/* Issue a non fatal error message. FILENAME, or if NULL then BFD, + are used to indicate the problematic file. SECTION, if non NULL, + is used to provide a section name. If FORMAT is non-null, then it + is used to print additional information via vfprintf. Finally the + bfd error message is printed. In summary, error messages are of + one of the following forms: + + PROGRAM:file: bfd-error-message + PROGRAM:file[section]: bfd-error-message + PROGRAM:file: printf-message: bfd-error-message + PROGRAM:file[section]: printf-message: bfd-error-message +*/ + +void +bfd_nonfatal_message (const char *filename, + const bfd *bfd, const asection *section, + const char *format, ...) +{ + const char *errmsg = bfd_errmsg (bfd_get_error ()); + const char *section_name = NULL; + va_list args; + + va_start (args, format); + fprintf (stderr, "%s", program_name); + + if (bfd) + { + if (!filename) + filename = bfd_get_filename (bfd); + if (section) + section_name = bfd_get_section_name (bfd, section); + } + if (section_name) + fprintf (stderr, ":%s[%s]", filename, section_name); + else + fprintf (stderr, ":%s", filename); + + if (format) + { + fprintf (stderr, ": "); + vfprintf (stderr, format, args); + } + fprintf (stderr, ": %s\n", errmsg); + va_end (args); +} + void bfd_fatal (const char *string) { |