Bug 34512 - The GCC manual about section variable attribute is incorrect
Summary: The GCC manual about section variable attribute is incorrect
Status: RESOLVED DUPLICATE of bug 34443
Alias: None
Product: gcc
Classification: Unclassified
Component: web (show other bugs)
Version: 4.2.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-17 15:54 UTC by Franck Bui-Huu
Modified: 2007-12-17 16:43 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Franck Bui-Huu 2007-12-17 15:54:19 UTC
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.

I would be nice to have all manuals reflecting this too.

Thanks !
Comment 1 Andrew Pinski 2007-12-17 16:43:13 UTC

*** This bug has been marked as a duplicate of 34443 ***