[PATCH v2] PE/COFF: auto-promote oversized objects to bigobj

Oleg Tolmatcev oleg.tolmatcev@gmail.com
Fri Jun 26 07:37:53 GMT 2026


Am Fr., 26. Juni 2026 um 08:59 Uhr schrieb Jan Beulich <jbeulich@suse.com>:
>
> On 23.06.2026 23:39, Oleg Tolmatcev wrote:
> > @@ -3154,6 +3158,16 @@ coff_compute_section_file_positions (bfd * abfd)
> >
> >    if (target_index >= bfd_coff_max_nscns (abfd))
> >      {
> > +#ifdef COFF_WITH_PE_BIGOBJ
> > +      if (abfd->xvec != &TARGET_SYM_BIG)
> > +     {
> > +       /* Regular PE/COFF uses 16-bit section numbers in symbols.
> > +          Promote oversized objects to the matching bigobj target
> > +          before any headers or symbols are finalized.  */
> > +       abfd->xvec = &TARGET_SYM_BIG;
> > +       return coff_compute_section_file_positions (abfd);
> > +     }
> > +#endif
> >        bfd_set_error (bfd_error_file_too_big);
> >        _bfd_error_handler
> >       /* xgettext:c-format */
>
> It occurs to me only now that this new behavior affects not only COFF
> objects, but also PE binaries. For the former the defaulting is imo okay
> (as previously indicated), as you'll notice when linking that the linker
> can't deal with the objects (and a newer linker needs using, or section
> count needs bringing down). For the latter, however, an executable may
> be produced which you have no way of knowing that it won't work with
> certain loaders (because all you can ever test with is a limited set of
> loaders). IOW I think the conditional may want to be
>
> #if defined(COFF_WITH_PE_BIGOBJ) && !defined(COFF_IMAGE_WITH_PE)
>
> Thoughts? I can certainly make that adjustment while committing, as
> long as we can come to an agreement.

I agree. The COFF objects case is the important one for me. Thanks.

Oleg.


More information about the Binutils mailing list