This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Link problems with section anchors
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: gcc-patches at gcc dot gnu dot org, David Edelsohn <dje at watson dot ibm dot com>, Steven Munroe <munroesj at us dot ibm dot com>, mark at codesourcery dot com, richard at codesourcery dot com
- Date: Wed, 9 Aug 2006 22:37:56 +0930
- Subject: Re: Link problems with section anchors
- References: <44D2755E.9020600@us.ibm.com> <20060804013032.GB23605@bubble.grove.modra.org> <87y7u427or.fsf@talisman.home> <200608041354.k74DsG832840@makai.watson.ibm.com> <87lkq41tx5.fsf@talisman.home> <200608041411.k74EBg832682@makai.watson.ibm.com> <20060809041155.GE6370@bubble.grove.modra.org> <87u04mctj1.fsf@talisman.home>
On Wed, Aug 09, 2006 at 07:28:18AM +0100, Richard Sandiford wrote:
> Yes, but as David says, changing _sections_ with the section attribute
> is fine. Our position is that changing program semantics isn't.
> And that's the difference between .sdata and .gnu.linkonce.
> The former doesn't change program semantics but the latter does.
Eh? Setting the section name to .gnu.linkonce.* _already_ changes
program semantics. The linker knows that .gnu.linkonce.* is special, at
least if you're using the GNU linker.
> Or to put it another way, recognising ".sdata" is just an optimisation.
> Nothing bad should happen if gcc fails to recognise a nonstandard
> section name that the user has chosen to place in the GP range.
> But bad things _do_ happen if gcc fails to treat something as link-once
> that actually is link-once.
You're arguing for my patch here. :-) GCC is currently ignorant of the
special section naming (when it is not the producer of such names) and
this ignorance causes it to mistreat an object that is actually
linkonce. I'm taking the position that the section name determines
whether an object is linkonce or not. This of course is a linker
centric view, but then, we're talking about something that affects
linker behaviour.
> I really think recognising ".gnu.linkonce" as a magic string is a bad
> idea. There was talk on #gcc at the time about adding a new attribute
> specifically for making something link-once. I still think that's the
> right way to go.
Perhaps so in an ideal world, but we already have a long-standing
convention that sections named .gnu.linkonce.* are magic. The new
attribute would of course be useful if you want to use comdat groups to
specify linkonce semantics.
Having said that, it appears that my main motivation for this patch has
disappeared as Jakub has removed the glibc usage of .gnu.linkonce in
generic code. I thought it was quite a neat trick.
--
Alan Modra
IBM OzLabs - Linux Technology Centre