This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: NOLOAD section attribute in gold.


On Mon, Sep 14, 2015 at 2:18 AM, Johan Karlsson <Johan.Karlsson@enea.com> wrote:
>
> Been trying to using my old linker scripts with gold and smoked out a couple
> of bugs so most things work now, however there are still some strange things
> going on when using the NOLOAD section attribute.
>
> It seems like NOLOAD means something different in gold compared to gnu ld.
>
> In gnu ld NOLOAD is the same as NOBITS with allocate flag set, like bss. In
> gold I get PROGBITS without any flags set, see
> Layout::make_output_section_for_script(),
>
> Iâve tried to change the behavior of this but make_output_section_for_script
> seems to create all sections that was not created during the linking phase,
> so there are some changes needed elsewhere for existing input sections.
>
> Another problem seems to be that NOBITS section are still allocated in the
> elf, this happens with a simple linker script which only had text, data, and
> bss sections and no additional attributes.
>
> So bss is uses memory in both in the elf and when creating a binary, this
> since filesize = memsize the the program header.
>
> Iâm willing to work on fixing this but I would like to discuss it first,
> because this behavior cannot be intended?

I've never really understood what NOLOAD is supposed to mean for ELF.
It was originally invented to set the STYP_NOLOAD bit in the output
section for COFF.  In COFF STYP_NOLOAD means a section that is
allocated in memory, and has real contents, but is not loaded from the
object file at run time.  ELF doesn't really have a way to describe
such a section.  The linker documentation for NOLOAD doesn't clarify
what it should mean for ELF.

Given this confusion, I'm not surprised that GNU ld and gold handle it
differently.  I have no particular objection to making gold do the
same thing as GNU ld.

The current support for NOLOAD in gold was added by Doug Kwan with
this patch: https://sourceware.org/ml/binutils/2010-04/msg00094.html

You should probably check with him about any changes.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]