Quote:
Originally Posted by
shamrock
The rodata section is a specific section of the text segment set aside for storing constants and literals for the purpose of efficiency as they can be embedded in the instructions passed to the CPU and so no overhead is incurred to fetch them from memory.
Sorry, no. This contradicts itself on many levels. You don't
embed something by
separating it into its own,
separate, independent segment -- that's the exact opposite of "embed". That it's not in the text segment indicates that it's
not in the text segment.
It's definitely not a part of CPU instructions here either. There
are CPU instructions that take a literal value, usually an integer or pointer of some sort, this isn't one of them. I'd believe that instructions can have embedded
pointers to fixed strings, or might embed some data from the read-only section when it's of convenient sizes to fit in instruction literals, but the
strings themselves are not embedded in the instructions, and therefore don't need to be embedded in the text segment.
Quote:
Another clue to the location of the literal is the fact that out of the 3 segments text data and stack only the text segment is readonly
This logic only works if you assume that
only text segments are read-only. This is not true.
This isn't to say there aren't architectures where strings might be embedded in the text segment for some reason, but this isn't one of them.