This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Return NULL on NULL bfd (Problem with linker with binutils-040414)
On Tue, Apr 20, 2004 at 08:54:32AM +0100, Nick Clifton wrote:
> Hi H. J.
>
> >How about this patch?
> >
> >
> >H.J.
> >----
> >2004-04-19 H.J. Lu <hongjiu.lu@intel.com>
> >
> > * bfd.c (bfd_archive_filename): Return NULL on NULL bfd.
> >
> >
> >
> This version of your patch (returning NULL) is approved for the
> mainline, and I suspect that Daniel will approve it for the branch.
>
> I agree that returning a NULL here can delay the detection of a problem,
> but that will be because of poor coding (ie not checking the return
> value of bfd_archive_filename) and in such cases the programmer gets
> what they deserve.
I am having the second thought. bfd_archive_filename was invented for
bfd error reporting. It is used as
prinf ("%s:....\n", bfd_archive_filename (), ...)
You will not get a core dump on NULL in this case, at least under
Linux. What you may get is the corrupted output. I don't think it
is realistic to change bfd to check return from bfd_archive_filename.
I think abort is more appropriate here.
H.J.