gcc puts .data and .bss symbols in .text segment.

Jim Wilson wilson@tuliptree.org
Wed Jun 18 23:44:00 GMT 2003


Henrik Stokseth wrote:
> Gcc puts symbols that should be 
> in .data or .bss into the .text segment instead. Why does Gcc do this, 
> and is this even allowed? 

Yes, it is allowed.  Read-only data goes in a .rodata section if it 
exists, otherwise it goes in the .text section.  If you are looking at 
object files instead of gcc output, you might be assuming stuff is in 
the text section that was actually in a different section to begin with, 
and then merged with the text section by the assembler or linker.

>  How does one tell if a symbol is 
> code, bss or data??? I am using gcc 3.2.x.

This isn't a gcc question.  It is a binutils question.  There should be 
info in the symbol table that can be used for this, at least in COFF.  I 
don't know OMF.  Please send further questions to the 
binutils@sources.redhat.com list.

Jim



More information about the Gcc mailing list