This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/51085] New: "volatile const" structures (in C) go in the .data section, not .rodata as expected


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51085

             Bug #: 51085
           Summary: "volatile const" structures (in C) go in the .data
                    section, not .rodata as expected
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: etienne_lorrain@yahoo.fr


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$


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]