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
Depends on:
Reported: 2011-11-10 17:34 UTC by etienne_lorrain
Modified: 2011-12-22 01:15 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed:


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.
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
	.align 4
	.type	array1, @object
	.size	array1, 12
	.long	1
	.long	2
	.long	3
	.globl	array2
	.section	.rodata,"aw",@progbits
	.align 4
	.type	array2, @object
	.size	array2, 12
	.long	1
	.long	2
	.long	3
	.globl	array3
	.section	.rodata #,"aw",@progbits
	.align 4
	.type	array3, @object
	.size	array3, 12
	.long	1
	.long	2
	.long	3
	.ident	"GCC: (Debian 4.6.1-15) 4.6.1"
	.section	.note.GNU-stack,"",@progbits
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 ***