[PATCH v2] bfd: Add bfd_unrecoverable_error for unrecoverable errors

H.J. Lu hjl.tools@gmail.com
Mon Oct 27 21:06:24 GMT 2025
On Tue, Oct 28, 2025 at 12:54 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 18.10.2025 03:03, H.J. Lu wrote:
> > Add bfd_update_error and update bfd_check_format_matches to handle memory
> > exhaustion.  This changes linker error message from
> >
> > ld:lib/libLLVMTransformUtils.a: file format not recognized; treating
> > as linker script
> > ld:lib/libLLVMTransformUtils.a:1: syntax error
> >
> > to
> >
> > ld: lib/libLLVMTransformUtils.a: file not recognized: memory exhausted
> >
> > when linking the 3.1GB clang executable in LLVM 21 debug build with the
> > 32-bit linker.
> >
> > PR ld/33550
> > * archive.c (bfd_generic_archive_p): Call bfd_update_error if
> > failed to read armap.
> > * bfd-in2.h: Regenerated.
> > * bfd.c (bfd_update_error): New.
> > * format.c (bfd_check_format_matches): Go out if memory is
> > exhausted.
>
> For this last change, aren't we then at risk of bailing out when really
> a later target could have matched (without running oom)? Also, why is

When we run out of memory, the current target may or may not
match.  Everything will go downhill from here.

> bfd_error_system_call special in bfd_update_error() but not here?
>
> Jan

Because I didn't hit bfd_error_system_call in my test.   Here is the v2
patch to add bfd_unrecoverable_error instead.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-bfd-Add-bfd_unrecoverable_error-for-unrecoverable.patch
Type: text/x-patch
Size: 3214 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20251028/0e2b0ea0/attachment-0002.bin>


More information about the Binutils mailing list