Problem with linker with binutils-040414
H. J. Lu
hjl@lucon.org
Mon Apr 19 14:31:00 GMT 2004
On Mon, Apr 19, 2004 at 10:35:52AM +0100, Nick Clifton wrote:
> Hi H. J.
>
> >I don't think it is a good idea. Linker should try to avoid core dump
> >on bad input. But linker should abort/core dump when there is an
> >internal bug. In this particular case, core dump helped uncover/fix the
> >linker bug. Otherwise, we might discover this bug much later. I suggest
> >we back out this patch or change it to
> >
> > if (abfd == NULL)
> > abort ();
> >
> >
> I disagree. The library should never abort. I can see the case for
> reporting internal errors with a sensible error message, but an abort
> (even with a message) is not correct. Possibly the caller of the
> library will be able to cope with the error and try another way to
> perform its function. Or maybe partial completion of the library's
> functions will allow the user to proceed further with the work that they
> are doing. Either way the library is providing a service to its
> caller. It should not dictate that the caller must terminate
> execution. Instead it should provide a sensible error indication and
> allow the caller to decide what to do.
I disagree. Did you mean "memset (0, 0, 1)" shouldn't segfault since
it was a library function? A NULL bfd won't give any meaningful
information in this case since the caller wants to get the filename.
The caller misuses the function and it deserves whatever it gets. I
don't believe it is wrong for a library not to support it misuse which
will only hide the caller's mistake and hurt the caller in the long
run.
H.J.
More information about the Binutils
mailing list