On Fri, Nov 19, 2004 at 09:33:19AM +0200, Nadav Har'El wrote:

> Does linux map these pages read-only? Doesn't it need to modify these pages
> while loading, e.g., to resolve references to other shared libraries, to
> change jump addresses, and so on?

I am guessing[0] that it will map the sections it can (e.g. rodata,
code) read only, and will map those it can't rw. Changing the code
pages should not be required, due to the way elf works. I am not
versed in the various magicks that take places (GOT, PLT, etc, etc),
but Gilad has a very good talk with excellent references on this here:
http://www.benyossef.com/presentations/dlink/

> And what does the new "prelink" thing do?

Whatever linking needs to be done, but earlier, before the application
is loaded. From: http://www.crast.us/james/articles/prelink.php

"Prelinking is a process that allows you to speed up the process of
dynamic linking. What it does is, through a process of magic that is
incredibly complex, but basically it speeds up the relocation process,
in loading shared libraries.. by setting preferred load addresses.

What is he talking about, you ask? Well, here's how it
goes. Dynamically linked libraries (often referred to as DSO's or in
the windows world DLLs) are libraries which are loaded at runtime. The
advantage of shared libraries versus static libraries is, that it
reduces the size of executables, since each program doesn't need its
libraries built in, but will dynamically locate and use it at run
time. This adds some overhead, because the address space of the
library, instead of being known in advance, has to be mapped at
runtime. Another advantage of shared libraries is that due to the
magic of copy-on-write, you can save memory when you have multiple
programs sharing the same library (though it's not as simple as
that.. it is pretty complicated)

Pre-linking sets preferred address space for the libraries to be
loaded at. Note they are _preferred_ spaces, and if that address space
is not available, then it will use relocation to load it
dynamically.. hence pre-linking is not 100% foolproof."

Cheers, 
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

Attachment: signature.asc
Description: Digital signature

Reply via email to