This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc puts .data and .bss symbols in .text segment.
Jim Wilson wrote:
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.
this optimalization can be done by passing the -R option to the
assembler i read. but assembly output from gcc confirms that gcc itself
does this optimalization by default. is there a way to turn it off on
the commandline? i couldn't find anything in the manual...
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.
Thanks. I probably will.
(again CC any answers to me as i'm not subscribed)
--
One OS to rule them all,
one OS to find them,
one OS to bring them all
and in the darkness bind them.