public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Clarification on section variable attribute usage [try #2]
@ 2007-12-10 20:59 Franck Bui-Huu
  2007-12-11 16:17 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Franck Bui-Huu @ 2007-12-10 20:59 UTC (permalink / raw)
  To: gcc, gcc-help

[ example updated ]

Hi,

Since at least 3.4, the GCC manual says:

     Use the `section' attribute with an _initialized_ definition of a
     _global_ variable, as shown in the example.  GCC issues a warning
     and otherwise ignores the `section' attribute in uninitialized
     variable declarations.

but this doesn't seem correct.

For example compiling the following tiny program:

	int foo __attribute__ ((__section__ (".init.data")));
	
	int main(int argc, char **argv)
	{
	        foo = 4;
	        return 0;
	}

produces no warning and the section attribute is not ignored at all:

	$ readelf -S a.out | grep -A1 init.data
	[24] .init.data        PROGBITS         000000000060080c  0000080c
	0000000000000004  0000000000000000  WA       0     0     4

This is with 4.1.2 from fedora, but I guess other GCC give the same result.

Could anybody clarify this point ?

Thanks,
		Franck

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Clarification on section variable attribute usage [try #2]
  2007-12-10 20:59 Clarification on section variable attribute usage [try #2] Franck Bui-Huu
@ 2007-12-11 16:17 ` Ian Lance Taylor
  2007-12-11 20:27   ` Franck Bui-Huu
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2007-12-11 16:17 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: gcc-help

Please never send a message to both gcc@gcc.gnu.org and
gcc-help@gcc.gnu.org.  Thanks.  I've dropped gcc@gcc.gnu.org from this
reply.

Franck Bui-Huu <vagabon.xyz@gmail.com> writes:

> Since at least 3.4, the GCC manual says:
> 
>      Use the `section' attribute with an _initialized_ definition of a
>      _global_ variable, as shown in the example.  GCC issues a warning
>      and otherwise ignores the `section' attribute in uninitialized
>      variable declarations.
> 
> but this doesn't seem correct.

Yes, I'm fairly sure that is no longer correct.  gcc is now smart
enough to not treat a variable with a section attribute as a common
variable.  I think the documentation is simply wrong.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Clarification on section variable attribute usage [try #2]
  2007-12-11 16:17 ` Ian Lance Taylor
@ 2007-12-11 20:27   ` Franck Bui-Huu
  2007-12-11 23:15     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Franck Bui-Huu @ 2007-12-11 20:27 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Hi Ian

Ian Lance Taylor wrote:
> Please never send a message to both gcc@gcc.gnu.org and
> gcc-help@gcc.gnu.org.  Thanks.
>

OK.

> Yes, I'm fairly sure that is no longer correct.  gcc is now smart
> enough to not treat a variable with a section attribute as a common
> variable.

Do you know when this happened ? Before GCC 3.2 ?

> I think the documentation is simply wrong.

It's probably high time to fix it up.

Thanks,
		Franck

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Clarification on section variable attribute usage [try #2]
  2007-12-11 20:27   ` Franck Bui-Huu
@ 2007-12-11 23:15     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2007-12-11 23:15 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: gcc-help

Franck Bui-Huu <vagabon.xyz@gmail.com> writes:

> > Yes, I'm fairly sure that is no longer correct.  gcc is now smart
> > enough to not treat a variable with a section attribute as a common
> > variable.
> 
> Do you know when this happened ? Before GCC 3.2 ?

I don't know when it happened, no.

> > I think the documentation is simply wrong.
> 
> It's probably high time to fix it up.

Yep.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-11 23:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-10 20:59 Clarification on section variable attribute usage [try #2] Franck Bui-Huu
2007-12-11 16:17 ` Ian Lance Taylor
2007-12-11 20:27   ` Franck Bui-Huu
2007-12-11 23:15     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).