gcc-patches@gcc.gnu.org
[Top] [All Lists]

Re: Link problems with section anchors

Subject: Re: Link problems with section anchors
From: Alan Modra
Date: Wed, 9 Aug 2006 22:37:56 +0930
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

<Prev in Thread] Current Thread [Next in Thread>