--- Begin Message ---
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: binutils <binutils at sources dot redhat dot com>
- Date: Wed, 22 Aug 2007 12:25:06 +0100
- Subject: Re: better error messages
- Organization: CodeSourcery
- References: <46AA13C0.9010505@codesourcery.com> <46B7445F.5000303@redhat.com> <46CB0134.50506@codesourcery.com>
Nathan Sidwell wrote:
Nick Clifton wrote:
Hi Nathan,
This patch adds a new bfd_nonfatal_message function, which produces
more informative messages naming the bfd and the section, where
applicable.
I agree with Andreas's comment that the new function needs to have a
comment header describing its inputs. In addition why did you remove
the RETURN_NONFATAL macro ? It would be cleaner to leave in place and
just change its argument to be the bfd.
Is this version ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2007-08-22 Nathan Sidwell <nathan@codesourcery.com>
* 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.
Index: bucomm.c
===================================================================
RCS file: /cvs/src/src/binutils/bucomm.c,v
retrieving revision 1.31
diff -c -3 -p -r1.31 bucomm.c
*** bucomm.c 5 Jul 2007 16:54:45 -0000 1.31
--- bucomm.c 22 Aug 2007 11:21:44 -0000
*************** bfd_nonfatal (const char *string)
*** 60,65 ****
--- 60,111 ----
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)
{
Index: bucomm.h
===================================================================
RCS file: /cvs/src/src/binutils/bucomm.h,v
retrieving revision 1.27
diff -c -3 -p -r1.27 bucomm.h
*** bucomm.h 5 Jul 2007 16:54:45 -0000 1.27
--- bucomm.h 22 Aug 2007 11:21:44 -0000
*************** const char *bfd_get_archive_filename (bf
*** 27,32 ****
--- 27,35 ----
void bfd_nonfatal (const char *);
+ void bfd_nonfatal_message (const char *, const bfd *, const asection *,
+ const char *, ...);
+
void bfd_fatal (const char *) ATTRIBUTE_NORETURN;
void report (const char *, va_list) ATTRIBUTE_PRINTF(1,0);
Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.117
diff -c -3 -p -r1.117 objcopy.c
*** objcopy.c 5 Jul 2007 16:54:45 -0000 1.117
--- objcopy.c 22 Aug 2007 11:21:46 -0000
*************** section_rename;
*** 64,70 ****
/* List of sections to be renamed. */
static section_rename *section_rename_list;
! #define RETURN_NONFATAL(s) {bfd_nonfatal (s); status = 1; return;}
static asymbol **isympp = NULL; /* Input symbols. */
static asymbol **osympp = NULL; /* Output symbols that survive stripping. */
--- 64,73 ----
/* List of sections to be renamed. */
static section_rename *section_rename_list;
! #define RETURN_NONFATAL(bfd) \
! do { \
! status = 1; bfd_nonfatal_message (NULL, bfd, NULL, NULL); return; \
! } while (0)
static asymbol **isympp = NULL; /* Input symbols. */
static asymbol **osympp = NULL; /* Output symbols that survive stripping. */
*************** copy_unknown_object (bfd *ibfd, bfd *obf
*** 1254,1260 ****
if (bfd_stat_arch_elt (ibfd, &buf) != 0)
{
! bfd_nonfatal (bfd_get_archive_filename (ibfd));
return FALSE;
}
--- 1257,1263 ----
if (bfd_stat_arch_elt (ibfd, &buf) != 0)
{
! bfd_nonfatal_message (bfd_get_archive_filename (ibfd), NULL, NULL, NULL);
return FALSE;
}
*************** copy_unknown_object (bfd *ibfd, bfd *obf
*** 1287,1293 ****
if (bfd_bread (cbuf, (bfd_size_type) tocopy, ibfd)
!= (bfd_size_type) tocopy)
{
! bfd_nonfatal (bfd_get_archive_filename (ibfd));
free (cbuf);
return FALSE;
}
--- 1290,1297 ----
if (bfd_bread (cbuf, (bfd_size_type) tocopy, ibfd)
!= (bfd_size_type) tocopy)
{
! bfd_nonfatal_message (bfd_get_archive_filename (ibfd),
! NULL, NULL, NULL);
free (cbuf);
return FALSE;
}
*************** copy_unknown_object (bfd *ibfd, bfd *obf
*** 1295,1301 ****
if (bfd_bwrite (cbuf, (bfd_size_type) tocopy, obfd)
!= (bfd_size_type) tocopy)
{
! bfd_nonfatal (bfd_get_filename (obfd));
free (cbuf);
return FALSE;
}
--- 1299,1305 ----
if (bfd_bwrite (cbuf, (bfd_size_type) tocopy, obfd)
!= (bfd_size_type) tocopy)
{
! bfd_nonfatal_message (NULL, obfd, NULL, NULL);
free (cbuf);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1332,1338 ****
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
{
! bfd_nonfatal (bfd_get_filename (obfd));
return FALSE;
}
--- 1336,1342 ----
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
{
! bfd_nonfatal_message (NULL, obfd, NULL, NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1366,1372 ****
if (!bfd_set_start_address (obfd, start)
|| !bfd_set_file_flags (obfd, flags))
{
! bfd_nonfatal (bfd_get_archive_filename (ibfd));
return FALSE;
}
}
--- 1370,1377 ----
if (!bfd_set_start_address (obfd, start)
|| !bfd_set_file_flags (obfd, flags))
{
! bfd_nonfatal_message (bfd_get_archive_filename (ibfd),
! NULL, NULL, NULL);
return FALSE;
}
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1390,1396 ****
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
{
! bfd_nonfatal (bfd_get_archive_filename (ibfd));
return FALSE;
}
--- 1395,1401 ----
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
{
! bfd_nonfatal_message (bfd_get_archive_filename (ibfd), NULL, NULL, NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1406,1412 ****
symsize = bfd_get_symtab_upper_bound (ibfd);
if (symsize < 0)
{
! bfd_nonfatal (bfd_get_archive_filename (ibfd));
return FALSE;
}
--- 1411,1417 ----
symsize = bfd_get_symtab_upper_bound (ibfd);
if (symsize < 0)
{
! bfd_nonfatal_message (bfd_get_archive_filename (ibfd), NULL, NULL, NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1414,1420 ****
symcount = bfd_canonicalize_symtab (ibfd, isympp);
if (symcount < 0)
{
! bfd_nonfatal (bfd_get_filename (ibfd));
return FALSE;
}
--- 1419,1425 ----
symcount = bfd_canonicalize_symtab (ibfd, isympp);
if (symcount < 0)
{
! bfd_nonfatal_message (NULL, ibfd, NULL, NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1445,1451 ****
error codes, so check for the most likely user error first. */
if (bfd_get_section_by_name (obfd, padd->name))
{
! non_fatal (_("can't add section '%s' - it already exists!"), padd->name);
return FALSE;
}
else
--- 1450,1457 ----
error codes, so check for the most likely user error first. */
if (bfd_get_section_by_name (obfd, padd->name))
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("can't add section '%s'"), padd->name);
return FALSE;
}
else
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1453,1467 ****
padd->section = bfd_make_section_with_flags (obfd, padd->name, flags);
if (padd->section == NULL)
{
! non_fatal (_("can't create section `%s': %s"),
! padd->name, bfd_errmsg (bfd_get_error ()));
return FALSE;
}
}
if (! bfd_set_section_size (obfd, padd->section, padd->size))
{
! bfd_nonfatal (bfd_get_filename (obfd));
return FALSE;
}
--- 1459,1474 ----
padd->section = bfd_make_section_with_flags (obfd, padd->name, flags);
if (padd->section == NULL)
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("can't create section `%s'"),
! padd->name);
return FALSE;
}
}
if (! bfd_set_section_size (obfd, padd->section, padd->size))
{
! bfd_nonfatal_message (NULL, obfd, padd->section, NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1471,1477 ****
if (! bfd_set_section_vma (obfd, padd->section,
pset->vma_val))
{
! bfd_nonfatal (bfd_get_filename (obfd));
return FALSE;
}
--- 1478,1484 ----
if (! bfd_set_section_vma (obfd, padd->section,
pset->vma_val))
{
! bfd_nonfatal_message (NULL, obfd, padd->section, NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1483,1489 ****
(obfd, padd->section,
bfd_section_alignment (obfd, padd->section)))
{
! bfd_nonfatal (bfd_get_filename (obfd));
return FALSE;
}
}
--- 1490,1496 ----
(obfd, padd->section,
bfd_section_alignment (obfd, padd->section)))
{
! bfd_nonfatal_message (NULL, obfd, padd->section, NULL);
return FALSE;
}
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1498,1504 ****
if (gnu_debuglink_section == NULL)
{
! bfd_nonfatal (gnu_debuglink_filename);
return FALSE;
}
--- 1505,1513 ----
if (gnu_debuglink_section == NULL)
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("cannot create debug link section `%s'"),
! gnu_debuglink_filename);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1589,1597 ****
if (! bfd_set_section_size (obfd, osections[i],
size + (gap_stop - gap_start)))
{
! non_fatal (_("Can't fill gap after %s: %s"),
! bfd_get_section_name (obfd, osections[i]),
! bfd_errmsg (bfd_get_error ()));
status = 1;
break;
}
--- 1598,1605 ----
if (! bfd_set_section_size (obfd, osections[i],
size + (gap_stop - gap_start)))
{
! bfd_nonfatal_message (NULL, obfd, osections[i],
! _("Can't fill gap after section"));
status = 1;
break;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1614,1622 ****
if (! bfd_set_section_size (obfd, osections[c - 1],
pad_to - lma))
{
! non_fatal (_("Can't add padding to %s: %s"),
! bfd_get_section_name (obfd, osections[c - 1]),
! bfd_errmsg (bfd_get_error ()));
status = 1;
}
else
--- 1622,1629 ----
if (! bfd_set_section_size (obfd, osections[c - 1],
pad_to - lma))
{
! bfd_nonfatal_message (NULL, obfd, osections[c - 1],
! _("can't add padding"));
status = 1;
}
else
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1695,1701 ****
if (! bfd_set_section_contents (obfd, padd->section, padd->contents,
0, padd->size))
{
! bfd_nonfatal (bfd_get_filename (obfd));
return FALSE;
}
}
--- 1702,1708 ----
if (! bfd_set_section_contents (obfd, padd->section, padd->contents,
0, padd->size))
{
! bfd_nonfatal_message (NULL, obfd, padd->section, NULL);
return FALSE;
}
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1706,1712 ****
if (! bfd_fill_in_gnu_debuglink_section
(obfd, gnu_debuglink_section, gnu_debuglink_filename))
{
! bfd_nonfatal (gnu_debuglink_filename);
return FALSE;
}
}
--- 1713,1721 ----
if (! bfd_fill_in_gnu_debuglink_section
(obfd, gnu_debuglink_section, gnu_debuglink_filename))
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("cannot fill debug link section `%s'"),
! gnu_debuglink_filename);
return FALSE;
}
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1745,1751 ****
if (! bfd_set_section_contents (obfd, osections[i], buf,
off, now))
{
! bfd_nonfatal (bfd_get_filename (obfd));
return FALSE;
}
--- 1754,1760 ----
if (! bfd_set_section_contents (obfd, osections[i], buf,
off, now))
{
! bfd_nonfatal_message (NULL, obfd, osections[i], NULL);
return FALSE;
}
*************** copy_object (bfd *ibfd, bfd *obfd)
*** 1767,1775 ****
important for the ECOFF code at least. */
if (! bfd_copy_private_bfd_data (ibfd, obfd))
{
! non_fatal (_("%s: error copying private BFD data: %s"),
! bfd_get_filename (obfd),
! bfd_errmsg (bfd_get_error ()));
return FALSE;
}
--- 1776,1783 ----
important for the ECOFF code at least. */
if (! bfd_copy_private_bfd_data (ibfd, obfd))
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("error copying private BFD data"));
return FALSE;
}
*************** copy_archive (bfd *ibfd, bfd *obfd, cons
*** 1828,1834 ****
this_element = bfd_openr_next_archived_file (ibfd, NULL);
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
! RETURN_NONFATAL (bfd_get_filename (obfd));
while (!status && this_element != NULL)
{
--- 1836,1842 ----
this_element = bfd_openr_next_archived_file (ibfd, NULL);
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
! RETURN_NONFATAL (obfd);
while (!status && this_element != NULL)
{
*************** copy_archive (bfd *ibfd, bfd *obfd, cons
*** 1885,1891 ****
output_bfd = bfd_openw (output_name, bfd_get_target (this_element));
if (output_bfd == NULL)
! RETURN_NONFATAL (output_name);
delete = ! copy_object (this_element, output_bfd);
--- 1893,1903 ----
output_bfd = bfd_openw (output_name, bfd_get_target (this_element));
if (output_bfd == NULL)
! {
! bfd_nonfatal_message (output_name, NULL, NULL, NULL);
! status = 1;
! return;
! }
delete = ! copy_object (this_element, output_bfd);
*************** copy_archive (bfd *ibfd, bfd *obfd, cons
*** 1894,1900 ****
{
if (!bfd_close (output_bfd))
{
! bfd_nonfatal (bfd_get_filename (output_bfd));
/* Error in new object file. Don't change archive. */
status = 1;
}
--- 1906,1912 ----
{
if (!bfd_close (output_bfd))
{
! bfd_nonfatal_message (NULL, output_bfd, NULL, NULL);
/* Error in new object file. Don't change archive. */
status = 1;
}
*************** copy_archive (bfd *ibfd, bfd *obfd, cons
*** 1904,1918 ****
}
else
{
! non_fatal (_("Unable to recognise the format of the input file `%s'"),
! bfd_get_archive_filename (this_element));
output_bfd = bfd_openw (output_name, output_target);
copy_unknown_element:
delete = !copy_unknown_object (this_element, output_bfd);
if (!bfd_close_all_done (output_bfd))
{
! bfd_nonfatal (bfd_get_filename (output_bfd));
/* Error in new object file. Don't change archive. */
status = 1;
}
--- 1916,1931 ----
}
else
{
! bfd_nonfatal_message (bfd_get_archive_filename (this_element),
! NULL, NULL,
! _("Unable to recognise the format of file"));
output_bfd = bfd_openw (output_name, output_target);
copy_unknown_element:
delete = !copy_unknown_object (this_element, output_bfd);
if (!bfd_close_all_done (output_bfd))
{
! bfd_nonfatal_message (NULL, output_bfd, NULL, NULL);
/* Error in new object file. Don't change archive. */
status = 1;
}
*************** copy_unknown_element:
*** 1946,1955 ****
*ptr = NULL;
if (!bfd_close (obfd))
! RETURN_NONFATAL (bfd_get_filename (obfd));
if (!bfd_close (ibfd))
! RETURN_NONFATAL (bfd_get_filename (ibfd));
/* Delete all the files that we opened. */
for (l = list; l != NULL; l = l->next)
--- 1959,1968 ----
*ptr = NULL;
if (!bfd_close (obfd))
! RETURN_NONFATAL (obfd);
if (!bfd_close (ibfd))
! RETURN_NONFATAL (obfd);
/* Delete all the files that we opened. */
for (l = list; l != NULL; l = l->next)
*************** copy_file (const char *input_filename, c
*** 1985,1991 ****
non-object file, failures are nonfatal. */
ibfd = bfd_openr (input_filename, input_target);
if (ibfd == NULL)
! RETURN_NONFATAL (input_filename);
if (bfd_check_format (ibfd, bfd_archive))
{
--- 1998,2008 ----
non-object file, failures are nonfatal. */
ibfd = bfd_openr (input_filename, input_target);
if (ibfd == NULL)
! {
! bfd_nonfatal_message (input_filename, NULL, NULL, NULL);
! status = 1;
! return;
! }
if (bfd_check_format (ibfd, bfd_archive))
{
*************** copy_file (const char *input_filename, c
*** 2004,2010 ****
obfd = bfd_openw (output_filename, output_target);
if (obfd == NULL)
! RETURN_NONFATAL (output_filename);
copy_archive (ibfd, obfd, output_target, force_output_target);
}
--- 2021,2031 ----
obfd = bfd_openw (output_filename, output_target);
if (obfd == NULL)
! {
! bfd_nonfatal_message (output_filename, NULL, NULL, NULL);
! status = 1;
! return;
! }
copy_archive (ibfd, obfd, output_target, force_output_target);
}
*************** copy_file (const char *input_filename, c
*** 2020,2036 ****
obfd = bfd_openw (output_filename, output_target);
if (obfd == NULL)
! RETURN_NONFATAL (output_filename);
if (! copy_object (ibfd, obfd))
status = 1;
if (!bfd_close (obfd))
! RETURN_NONFATAL (output_filename);
if (!bfd_close (ibfd))
! RETURN_NONFATAL (input_filename);
!
}
else
{
--- 2041,2060 ----
obfd = bfd_openw (output_filename, output_target);
if (obfd == NULL)
! {
! bfd_nonfatal_message (output_filename, NULL, NULL, NULL);
! status = 1;
! return;
! }
if (! copy_object (ibfd, obfd))
status = 1;
if (!bfd_close (obfd))
! RETURN_NONFATAL (obfd);
if (!bfd_close (ibfd))
! RETURN_NONFATAL (ibfd);
}
else
{
*************** copy_file (const char *input_filename, c
*** 2050,2056 ****
if (obj_error != core_error)
bfd_set_error (obj_error);
! bfd_nonfatal (input_filename);
if (obj_error == bfd_error_file_ambiguously_recognized)
{
--- 2074,2080 ----
if (obj_error != core_error)
bfd_set_error (obj_error);
! bfd_nonfatal_message (input_filename, NULL, NULL, NULL);
if (obj_error == bfd_error_file_ambiguously_recognized)
{
*************** find_section_rename (bfd * ibfd ATTRIBUT
*** 2129,2152 ****
static void
setup_bfd_headers (bfd *ibfd, bfd *obfd)
{
- const char *err;
-
/* Allow the BFD backend to copy any private data it understands
from the input section to the output section. */
if (! bfd_copy_private_header_data (ibfd, obfd))
{
! err = _("private header data");
! goto loser;
}
/* All went well. */
return;
-
- loser:
- non_fatal (_("%s: error in %s: %s"),
- bfd_get_filename (ibfd),
- err, bfd_errmsg (bfd_get_error ()));
- status = 1;
}
/* Create a section in OBFD with the same
--- 2153,2170 ----
static void
setup_bfd_headers (bfd *ibfd, bfd *obfd)
{
/* Allow the BFD backend to copy any private data it understands
from the input section to the output section. */
if (! bfd_copy_private_header_data (ibfd, obfd))
{
! status = 1;
! bfd_nonfatal_message (NULL, ibfd, NULL,
! _("error in private h eader data"));
! return;
}
/* All went well. */
return;
}
/* Create a section in OBFD with the same
*************** setup_section (bfd *ibfd, sec_ptr isecti
*** 2204,2210 ****
if (osection == NULL)
{
! err = _("making");
goto loser;
}
--- 2222,2228 ----
if (osection == NULL)
{
! err = _("failed to create output section");
goto loser;
}
*************** setup_section (bfd *ibfd, sec_ptr isecti
*** 2224,2230 ****
size = 0;
if (! bfd_set_section_size (obfd, osection, size))
{
! err = _("size");
goto loser;
}
--- 2242,2248 ----
size = 0;
if (! bfd_set_section_size (obfd, osection, size))
{
! err = _("failed to set size");
goto loser;
}
*************** setup_section (bfd *ibfd, sec_ptr isecti
*** 2238,2244 ****
if (! bfd_set_section_vma (obfd, osection, extract_symbol ? 0 : vma))
{
! err = _("vma");
goto loser;
}
--- 2256,2262 ----
if (! bfd_set_section_vma (obfd, osection, extract_symbol ? 0 : vma))
{
! err = _("failed to set vma");
goto loser;
}
*************** setup_section (bfd *ibfd, sec_ptr isecti
*** 2263,2269 ****
osection,
bfd_section_alignment (ibfd, isection)))
{
! err = _("alignment");
goto loser;
}
--- 2281,2287 ----
osection,
bfd_section_alignment (ibfd, isection)))
{
! err = _("failed to set alignment");
goto loser;
}
*************** setup_section (bfd *ibfd, sec_ptr isecti
*** 2285,2291 ****
from the input section to the output section. */
if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
{
! err = _("private data");
goto loser;
}
else if ((isection->flags & SEC_GROUP) != 0)
--- 2303,2309 ----
from the input section to the output section. */
if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
{
! err = _("failed to copy private data");
goto loser;
}
else if ((isection->flags & SEC_GROUP) != 0)
*************** setup_section (bfd *ibfd, sec_ptr isecti
*** 2300,2310 ****
return;
loser:
- non_fatal (_("%s: section `%s': error in %s: %s"),
- bfd_get_filename (ibfd),
- bfd_section_name (ibfd, isection),
- err, bfd_errmsg (bfd_get_error ()));
status = 1;
}
/* Copy the data of input section ISECTION of IBFD
--- 2318,2325 ----
return;
loser:
status = 1;
+ bfd_nonfatal_message (NULL, obfd, osection, err);
}
/* Copy the data of input section ISECTION of IBFD
*************** copy_section (bfd *ibfd, sec_ptr isectio
*** 2356,2362 ****
if (relsize == -1 && bfd_get_error () == bfd_error_invalid_operation)
relsize = 0;
else
! RETURN_NONFATAL (bfd_get_filename (ibfd));
}
}
--- 2371,2381 ----
if (relsize == -1 && bfd_get_error () == bfd_error_invalid_operation)
relsize = 0;
else
! {
! status = 1;
! bfd_nonfatal_message (NULL, ibfd, isection, NULL);
! return;
! }
}
}
*************** copy_section (bfd *ibfd, sec_ptr isectio
*** 2367,2373 ****
relpp = xmalloc (relsize);
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
if (relcount < 0)
! RETURN_NONFATAL (bfd_get_filename (ibfd));
if (strip_symbols == STRIP_ALL)
{
--- 2386,2397 ----
relpp = xmalloc (relsize);
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
if (relcount < 0)
! {
! status = 1;
! bfd_nonfatal_message (NULL, ibfd, isection,
! _("relocation count is negative"));
! return;
! }
if (strip_symbols == STRIP_ALL)
{
*************** copy_section (bfd *ibfd, sec_ptr isectio
*** 2401,2407 ****
void *memhunk = xmalloc (size);
if (!bfd_get_section_contents (ibfd, isection, memhunk, 0, size))
! RETURN_NONFATAL (bfd_get_filename (ibfd));
if (reverse_bytes)
{
--- 2425,2435 ----
void *memhunk = xmalloc (size);
if (!bfd_get_section_contents (ibfd, isection, memhunk, 0, size))
! {
! status = 1;
! bfd_nonfatal_message (NULL, ibfd, isection, NULL);
! return;
! }
if (reverse_bytes)
{
*************** copy_section (bfd *ibfd, sec_ptr isectio
*** 2444,2451 ****
}
if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
! RETURN_NONFATAL (bfd_get_filename (obfd));
!
free (memhunk);
}
else if (p != NULL && p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0)
--- 2472,2482 ----
}
if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
! {
! status = 1;
! bfd_nonfatal_message (NULL, obfd, osection, NULL);
! return;
! }
free (memhunk);
}
else if (p != NULL && p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0)
*************** copy_section (bfd *ibfd, sec_ptr isectio
*** 2460,2466 ****
memset (memhunk, 0, size);
if (! bfd_set_section_contents (obfd, osection, memhunk, 0, size))
! RETURN_NONFATAL (bfd_get_filename (obfd));
free (memhunk);
}
}
--- 2491,2501 ----
memset (memhunk, 0, size);
if (! bfd_set_section_contents (obfd, osection, memhunk, 0, size))
! {
! status = 1;
! bfd_nonfatal_message (NULL, obfd, osection, NULL);
! return;
! }
free (memhunk);
}
}
*************** write_debugging_info (bfd *obfd, void *d
*** 2601,2609 ****
|| ! bfd_set_section_alignment (obfd, stabsec, 2)
|| ! bfd_set_section_alignment (obfd, stabstrsec, 0))
{
! non_fatal (_("%s: can't create debugging section: %s"),
! bfd_get_filename (obfd),
! bfd_errmsg (bfd_get_error ()));
return FALSE;
}
--- 2636,2643 ----
|| ! bfd_set_section_alignment (obfd, stabsec, 2)
|| ! bfd_set_section_alignment (obfd, stabstrsec, 0))
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("can't create debugging section"));
return FALSE;
}
*************** write_debugging_info (bfd *obfd, void *d
*** 2615,2631 ****
|| ! bfd_set_section_contents (obfd, stabstrsec, strings, 0,
stringsize))
{
! non_fatal (_("%s: can't set debugging section contents: %s"),
! bfd_get_filename (obfd),
! bfd_errmsg (bfd_get_error ()));
return FALSE;
}
return TRUE;
}
! non_fatal (_("%s: don't know how to write debugging information for %s"),
! bfd_get_filename (obfd), bfd_get_target (obfd));
return FALSE;
}
--- 2649,2665 ----
|| ! bfd_set_section_contents (obfd, stabstrsec, strings, 0,
stringsize))
{
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("can't set debugging section contents"));
return FALSE;
}
return TRUE;
}
! bfd_nonfatal_message (NULL, obfd, NULL,
! _("don't know how to write debugging information for %s"),
! bfd_get_target (obfd));
return FALSE;
}
*************** strip_main (int argc, char *argv[])
*** 2765,2772 ****
if (tmpname == NULL)
{
! non_fatal (_("could not create temporary file to hold stripped copy of '%s'"),
! argv[i]);
status = 1;
continue;
}
--- 2799,2806 ----
if (tmpname == NULL)
{
! bfd_nonfatal_message (argv[i], NULL, NULL,
! _("could not create temporary file to hold stripped copy"));
status = 1;
continue;
}
--- End Message ---