Query on linker scripts
Dave Hylands
dhylands at gmail.com
Mon Mar 26 11:14:05 EDT 2012
Hi Vaibhav Jain,
On Mon, Mar 26, 2012 at 4:01 AM, Vaibhav Jain <vjoss197 at gmail.com> wrote:
> Thanks a lot for the explanation and the link!! I have just one more
> question about
> linker scripts. I am not clear about alignment of sections. Is it necessary
> to align sections?
> Can the alignment be different from 4096?
> In the script that I provided the text and data sections are aligned while
> the bss section is not. Is there
> a reason for it ?
The reason for using page alignments is so that the kernel can enforce
different access types to the various sections. This is tyically done
using the MMU, which would require page alignment.
So, for example, the text section would allow executable code, and
should be read-only. The .rodata section should not allow executable
code and be read-only, and the .data section should not allow
executable code, and should allow writes.
By having the sections page aligned, it allows the kernel to enforce
these using the MMU.
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
More information about the Kernelnewbies
mailing list