[bitlug] where in the mem layout does .rodata go?

  • From: "pavan t chandra" <pavan_tc@xxxxxxxxxxxxxx>
  • To: bitlug@xxxxxxxxxxxxx
  • Date: 27 Apr 2004 04:35:22 -0000

>  I saw that a separate section called ".rodata" was present( as told by tc),
>and this section is not part of ".text" nor ".bss". It was also seen that
>the .text and the .rodata sections go into the same page( in the last talk).
>the description of rodata is perfectly ok. But .rodata being present in the
>same page as .text, where the page is marked "executable" is not acceptable.

oh wow ppl,
I am thrilled to find this discussion.
The very same question was asked by some one to none other than Linus Torvalds, 
and here is the guru's reply:

http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0527.html

For the question,
http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0497.html

we can see that there has been a discussion on this, on lkml.

Just one more thought to add to all this.

Let us think, what kind of threat would .rodata present to the code?This can 
first of all, originate only from within the code. Which means to say that the 
programmer, unless willingly, will put _only_ "sensible" data within the 
section and not malicious executable code.

So, the compiler does arrange to put things in the same page.

One more important piece of info in Linus' discussion is that of alignment. We 
hadnt thought about it. The I-Cache and D-Cache will be seriously hit, if the 
code and data come in the same cache line.

Maybe, we can have a small discussion on this in the next session?

TC

Other related posts:

  • » [bitlug] where in the mem layout does .rodata go?