Hi, 
 
in the following small example program, g++ puts the constant data into 
the .data section and not into .rodata as it should. It works just fine with 
the C frontend. This is a regression from at least 3.3/3.4. 
 
Cheers, 
Lars 
 
[EMAIL PROTECTED] rodata]$ cat main.c 
const char rodata[] = "Hello World"; 
 
const char * foo() { return rodata; } 
[EMAIL PROTECTED] rodata]$ g++ -c main.c 
[EMAIL PROTECTED] rodata]$ objdump -h main.o 
 
main.o:     file format elf64-x86-64 
 
Sections: 
Idx Name          Size      VMA               LMA               File off  Algn 
  0 .text         0000000b  0000000000000000  0000000000000000  00000040  2**2 
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 
  1 .data         0000000c  0000000000000000  0000000000000000  0000004c  2**2 
                  CONTENTS, ALLOC, LOAD, DATA 
  2 .bss          00000000  0000000000000000  0000000000000000  00000058  2**2 
                  ALLOC 
  3 .eh_frame     00000048  0000000000000000  0000000000000000  00000058  2**3 
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 
  4 .comment      00000028  0000000000000000  0000000000000000  000000a0  2**0 
                  CONTENTS, READONLY 
  5 .note.GNU-stack 00000000  0000000000000000  0000000000000000  000000c8  
2**0 
                  CONTENTS, READONLY 
[EMAIL PROTECTED] rodata]$ gcc -c main.c 
[EMAIL PROTECTED] rodata]$ objdump -h main.o 
 
main.o:     file format elf64-x86-64 
 
Sections: 
Idx Name          Size      VMA               LMA               File off  Algn 
  0 .text         0000000b  0000000000000000  0000000000000000  00000040  2**2 
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 
  1 .data         00000000  0000000000000000  0000000000000000  0000004c  2**2 
                  CONTENTS, ALLOC, LOAD, DATA 
  2 .bss          00000000  0000000000000000  0000000000000000  0000004c  2**2 
                  ALLOC 
  3 .rodata       0000000c  0000000000000000  0000000000000000  0000004c  2**0 
                  CONTENTS, ALLOC, LOAD, READONLY, DATA 
  4 .eh_frame     00000038  0000000000000000  0000000000000000  00000058  2**3 
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 
  5 .comment      00000028  0000000000000000  0000000000000000  00000090  2**0 
                  CONTENTS, READONLY 
  6 .note.GNU-stack 00000000  0000000000000000  0000000000000000  000000b8  
2**0 
                  CONTENTS, READONLY

-- 
           Summary: g++ puts read only data into the .data section
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lars at trolltech dot com
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to