[PATCH] Orphan sections and NOLOAD output section
Jan Beulich
jbeulich@suse.com
Thu Apr 21 15:53:57 GMT 2022
On 21.04.2022 17:31, Eric Botcazou via Binutils wrote:
> we recently got a report about a counter-intuitive behavior of the GNU linker
> for orphan sections matched by a NOLOAD output section, which turned out to be
> an exact duplicate of:
> https://stackoverflow.com/questions/48764136/gcc-noload-directive-cause-wrong-memory-mapping
>
> What happens is that the effect of the command:
>
> .foo (NOLOAD) : {}
>
> is not equivalent to that of:
>
> .foo (NOLOAD) : { *(.foo) }
>
> when there is more than 1 object file containing a .foo section: the former
> will output two .foo sections, the first with PROGBITS and the second with
> NOBITS, where the latter will output only one with NOBITS.
>
> I think that the commands are essentially equivalent so the linker ought to yield
> the same outcome, namely the single output section with NOBITS.
Hmm, not having found any statement as to potentially special
meaning of nothing inside the braces, I'm not convinced the two
are "essentially equivalent". What I'm puzzled by though is your
reference to there needing to be more than one object file
involved - I wouldn't expect the behavior to depend on the number
of object files contributing to a section. Instead I'd expect a
single object file to similarly result in two .foo sections in
the output.
Jan
More information about the Binutils
mailing list