Need help understanding memory models, cpu modes and address translation

Joel A Fernandes agnel.joel at gmail.com
Sat Jul 16 01:02:22 EDT 2011


Hi Mulyadi,

Good to read your posts. It has certainly been a long time and it
feels good to be back on this list!

> On Sat, Jul 16, 2011 at 10:14, Vaibhav Jain <vjoss197 at gmail.com> wrote:
....
>
>> Could somebody please state the difference clearly for me and explain how
>> these two work together. I would
>> really appreciate if someone could explain the whole chain from generation
>> of addresses by compiler and then translation of
>> those addresses in case of  Segmentation working along with Paging.
>
> when you generate object code from your source code (let's say in C)
> using gcc, first your code and variables (data) are turn into Position
> Independent Code. It means, it is just an offset. If there is an
> offset, surely we need base address, right? But not at this object
> (resulting in .o) stage.
>
> Then in reach producing final ELF binary (executable). Using known
> standart ELF rule, those offset are turn into final final address. So
> let's, code are placed starting at 0x080499f0 and so on.

Very nice explanation!

>
> When that binary is loaded into memory, loader (ld.so) take that
> information and use it as a clue on where to put the code and data.
> Using standart mmap() syscall, memory area is reserved and data/code
> is loaded there. The exception is stack, where it is allocated
> dynamically (and grows down, for Intel arch) starting at the upper
> limit of user space (near 3 GiB).
>

I'm just a little troubled by this bit.

AFAIK, the kernel takes ELF executables and loads them into the
appropriate sections after parsing the ELF tables and headers. Correct
me if I'm wrong? Ofcourse, ld.so takes care of dynamic linking/loading
shared libraries into the address space.

Thanks,
Joel



More information about the Kernelnewbies mailing list