bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/18935] Gold assert fail when moving dot in NOLOAD section.


From: johan.karlsson at enea dot com
Subject: [Bug gold/18935] Gold assert fail when moving dot in NOLOAD section.
Date: Tue, 15 Sep 2015 07:04:53 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=18935

--- Comment #3 from Johan Karlsson <johan.karlsson at enea dot com> ---
(In reply to Cary Coutant from comment #2)
> > Seems a bit unclear what the expected behavior is.
> >
> >  .init_stack (NOLOAD) :
> >  {
> >    . = . + 0x200;
> >  } :ph_load
> > With this ld.bfd creates a NOBITS SHF_ALLOC section(just like .bss).
> >
> > When a new non-SHF_ALLOC output section is created the address is set to 0.
> > Layout::make_output_section_for_script(), which is the function that creates
> > the init_stack section, only tries to create sections with SHT_PROGBITS
> > section. This is why the assert fails when
> > Output_section_definition::set_section_addresses() tries to assign an 
> > address
> > to the section.
> 
> This script looks like it's trying to create an unloadable section,
> then allocate it to a loadable segment. If all the script is trying to
> do is create a loadable NOBITS section, the NOLOAD attribute shouldn't
> be necessary (or allowed). The fact that it contains nothing but
> uninitialized space should be sufficient. I don't think gold does the
> right thing in that case, but that ought to be the bug, not that
> NOLOAD should make it work.
> 
> What does Gnu ld do if you omit NOLOAD? Do you have any history that
> explains why NOLOAD was added to the script?
> 
> -cary

When removing NOLOAD Gnu ld still makes it a NOBITS section, guess it
recognizes that it is empty and does that. Because if I just add an int to that
section it will create it as PROGBITS. And if I then add the NOLOAD again it is
back to NOBITS.

The linker scripts are for embedded systems that usually load binaries. So if
we put things in NOLOAD section the binaries are smaller.

This PR is highly tied to the discussion in the mailing list. Seems like NOLOAD
is implemented in gold just as described by the linker documentation. 
However Gnu ld does not do that for ELF, see ld/ldlang.c

      /* Unfortunately GNU ld has managed to evolve two different
         meanings to NOLOAD in scripts.  ELF gets a .bss style noload,
         alloc, no contents section.  All others get a noload, noalloc
         section.  */

I think the best is to change the behavior of gold to be compatible with Gnu
ld.

/Johan

-- 
You are receiving this mail because:
You are on the CC list for the bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]