This is the mail archive of the
mailing list for the GCC project.
Re: What do the .gnu.linkonce.* sections contain ?
- To: "Beier, Niels" <niels dot beier at intel dot com>
- Subject: Re: What do the .gnu.linkonce.* sections contain ?
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- Date: 22 May 2001 16:10:57 +0100
- Cc: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- References: <CD4DE0181670D211AC5400A0C94BD1B801601B77@dksmsx30.idk.intel.com>
> 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++
> 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
PS. See also the description of DECL_LINKONCE_P in gcc/c-tree.texi.