[PATCH] ld: Clear SEC_ALLOC for NOLOAD notes sections

H.J. Lu hjl.tools@gmail.com
Fri Mar 14 01:02:47 GMT 2025


On Thu, Mar 13, 2025 at 5:40 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Thu, Mar 13, 2025 at 12:14:50PM -0700, H.J. Lu wrote:
> > If a note section is marked as NOLOAD, clear the SEC_ALLOC so that it
> > won't be treated as an SHF_ALLOC section, like a .bss section.
>
> Perhaps we should instead make NOLOAD consistent over all targets?
> That might not be possible, at least I thought so at the time I wrote
> that "Unfortunately.." comment, but it is nasty that NOLOAD behaves
> differently for ELF.

Can we make the exception only for .bss sections, like

     if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
          && startswith (section->name, ".bss"))
        flags &= ~SEC_HAS_CONTENTS;
      else
        flags &= ~SEC_ALLOC;


> --
> Alan Modra



-- 
H.J.


More information about the Binutils mailing list