This is the mail archive of the
mailing list for the binutils project.
Re: NOLOAD section attribute in gold.
- From: Ian Lance Taylor <iant at google dot com>
- To: Johan Karlsson <Johan dot Karlsson at enea dot com>
- Cc: Binutils <binutils at sourceware dot org>, Cary Coutant <ccoutant at gmail dot com>
- Date: Mon, 14 Sep 2015 08:21:15 -0700
- Subject: Re: NOLOAD section attribute in gold.
- Authentication-results: sourceware.org; auth=none
- References: <5006DF1F5103294E8DA02CC4C71B1BF8087392A0 at SESTOEX04 dot enea dot se>
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
> 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.