This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: What do the .gnu.linkonce.* sections contain ?


Hi Niels,

> I am wondering whether I need to include the .gnu.linkonce.*
> sections in the final image downloaded to the target (an embedded
> platform using an arm cpu). It is only generated when compiling C++
> code.

Yes.
 
> Could anyone provide some help?

The linkonce sections are used to hold multiple copies of the same
code.  When the final link is done, all of these multiple copies will
be merged into a single copy in the final executable.  Of course if
two linkonce sections are different then they should not be merged,
but the linker determines this based on the *name* if the linkonce
section, not its *contents*, so careful if you should ever end up
generating these things by hand.

Why would C++ generate multiple copies of the same function ?  All
kinds of reasons really.  Template instantiations, for example.  All
that matters is that it does generate them, and so it is important
that they do get downloaded to the target hardware along with the
"normal" sections.

Cheers
        Nick

PS. See also the description of DECL_LINKONCE_P in gcc/c-tree.texi.



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