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.
- From: Mike Stump <mrs at apple dot com>
- To: Henrik Stokseth <hensto at online dot no>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 18 Jun 2003 14:17:32 -0700
- Subject: Re: gcc puts .data and .bss symbols in .text segment.
On Tuesday, June 17, 2003, at 09:55 PM, Henrik Stokseth wrote:
I'm currently wriring on a tool to convert between OMF and COFF object
file formats. Doing so i have stumbled upon something rather strange
in the object output from the gcc compiler. Gcc puts symbols that
should be in .data or .bss into the .text segment instead.
Should be, hum, interesting concept.
Why does Gcc do this, and is this even allowed?
Because it is better. Yes, often time, not always. Why is it better,
the usual reason is so that difference invocations of a program can
share read-only pages of the executable program so as to improve
program startup time, forking, reduce the amount of memory allocated,
reduce the amount of swap allocated... Also, this optimization can
reduce the amount of RAM a system needs at the expense of making the
ROM larger.
How does one tell if a symbol is code, bss or data???
The question is to vague to answer. In general, you don't get to know.
The debugging format can give you more details about some symbols, if
the code was compiled with -g. In some OMFs you can get the compiler
to type symbols for you (code, data).
A symbol that refers to stuff in the bss section, refers to stuff in
the bss segment. A symbol that refers to stuff in the data section,
refers to stuff in the data section. But I can't imagine that answered
your question.