Unix Programming - Re: excec( ) implementation basics [are ELFs mmap-ed to Process Address

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2006 > Re: excec( ) implementation basics [are ELFs mmap-ed to Process Address





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 Re: excec( ) implementation basics [are ELFs mmap-ed to Process Address
moi

2006-01-18, 5:55 pm

50295@web.de wrote:
> Hi -
>
> I've been stracing loads of stuff lately, trying to and I'm wondering
> how mmap actually words/is implemented on *NIX systems. I suspect
> mmaping the executable (elf binary) to the process' address space would
> be a good idea. Is this how mmap is implemented? I know shared
> libraries are are implemented with mmap (and quite possibly shared
> memory i.e. shmget etc), but I'm not sure how exec() is implemented.
> Hints anyone?


The best way, IMHO is to look upon it is in terms of hardware/MMU.
mmap makes clever use of the hardware, by setting up pagetable-entries,
which point to the address space and the appropriate diskpages.
The first access to a mmapped page wil cause a (page not present)
pagefault, and the page will be read in by the pagefault handler.
("faulted in")

Copy-on-write is just a useful extension to this scheme.
Execution of pages is basically the same, except for relocations,
which have to be fixed up by the loader. Don't know how that works,
I suggest you need to read the sources for that ;-]

> Please dont ask me to take a look at the source. I have, but it made my
> head spin.
>


It is supposed to make the disks spin, not your head.

> Thanks,
>
> - Olumide
>


HTH,
AvK
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com