User account creation filtered due to spam.

Bug 51085 - "volatile const" structures (in C) go in the .data section, not .rodata as expected
Summary: "volatile const" structures (in C) go in the .data section, not .rodata as ex...
Status: RESOLVED DUPLICATE of bug 25521
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-10 17:34 UTC by etienne_lorrain
Modified: 2011-12-22 01:15 UTC (History)
0 users

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 etienne_lorrain 2011-11-10 17:34:43 UTC
Basically, I was hoping (maybe my fault?) that "volatile const" data would go to .rodata segment.
As described in the example for array1, that is not the case.
The example show array2, but to stop an asm message changing attribute of a section I need the dirty trick of array3.
I did not noticed that with previous compiler version.


etienne@debian-testing:~/projet$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.6/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.1-15' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.6.1 (Debian 4.6.1-15) 
etienne@debian-testing:~/projet$ cat text.c 
volatile const unsigned array1[3] = { 1, 2, 3 };
volatile const unsigned array2[3] __attribute__ ((section(".rodata"))) = { 1, 2, 3 };
volatile const unsigned array3[3] __attribute__ ((section(".rodata #"))) = { 1, 2, 3 };
etienne@debian-testing:~/projet$ gcc -S text.c -o -
	.file	"text.c"
	.globl	array1
	.data
	.align 4
	.type	array1, @object
	.size	array1, 12
array1:
	.long	1
	.long	2
	.long	3
	.globl	array2
	.section	.rodata,"aw",@progbits
	.align 4
	.type	array2, @object
	.size	array2, 12
array2:
	.long	1
	.long	2
	.long	3
	.globl	array3
	.section	.rodata #,"aw",@progbits
	.align 4
	.type	array3, @object
	.size	array3, 12
array3:
	.long	1
	.long	2
	.long	3
	.ident	"GCC: (Debian 4.6.1-15) 4.6.1"
	.section	.note.GNU-stack,"",@progbits
etienne@debian-testing:~/projet$
Comment 1 Andrew Pinski 2011-12-22 01:15:48 UTC
Dup of an older bug.

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