|
Home > Archive > Unix questions > March 2005 > about .rodata and constants
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
about .rodata and constants
|
|
|
| I see that unless I use -fwritable-strings, gcc puts my constants
such as "foo" in the section .rodata. I also see that whatever I
declare with the keyword const, gcc puts it in .rodata.
I observed this in GNU/Linux, FreeBSD and Solaris.
My question is: is this the way gcc does for all UNIX-like
systems? I believe the answer could be something like: all
systems which use ELF format (or some other standard).
Thanks for information on this.
| |
|
| On Sat, 26 Mar 2005 22:11:37 +0000,
Kevin <kevin@hotmail.com> wrote:
> I see that unless I use -fwritable-strings, gcc puts my
> constants such as "foo" in the section .rodata. I also see that
> whatever I declare with the keyword const, gcc puts it in
> .rodata.
>
> I observed this in GNU/Linux, FreeBSD and Solaris.
>
> My question is: is this the way gcc does for all UNIX-like
> systems? I believe the answer could be something like: all
> systems which use ELF format (or some other standard).
>
> Thanks for information on this.
Maybe my question is unanswerable or unworthy of a an answer;
probably the latter. I will post a summary of the whole story.
On this URL below, you can see the authors saying:
http://www-ee.eng.hawaii.edu/Course...ion2.1.1.8.html
``When a program is loaded into memory, it is organized into
three areas of memory, called segments: the text segment, stack
segment, and heap segment.''
I was studying how literal constants are stored in a executable,
so that I could have an idea of which ``part'' of the memory my
program would be accessing when reading these constants.
I don't like the fact that some authors classify the executable
as the ``text segment'' because it seems to mislead people into
thinking that the whole executable is the .text *section* of an
assembly program.
And I was talking to someone who said ``all literal constants are
stored in the text segment''. Well, I thought, this is just
wrong. They are stored in .data or .rodata. Later, I figured we
were talking about different things. The person was actually
saying ``the literal constants are stored in the executable'' and
I was saying ``the literal constants are in the .data or .rodata
section of the executable'', so it was a communication problem.
However, that the literal constants are in the executable is
pretty obvious, I think.
So I thought of research to find out if there is any system or
executable format that doesn't make any distinction between these
sections, so literal constants wouldn't be in a specific section
of the executable.
I hope I didn't make it worse, now. Thank you.
|
|
|
|
|