This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Shared library mapped to different parts of the address space
- From: Ian Lance Taylor <iant at google dot com>
- To: "Rodrigo Dominguez" <roddomi at hotmail dot com>
- Cc: <binutils at sourceware dot org>
- Date: Wed, 23 Apr 2008 14:34:37 -0700
- Subject: Re: Shared library mapped to different parts of the address space
- References: <BAY109-DAV61A88A2F83FB33245D5AFB9E30@phx.gbl>
"Rodrigo Dominguez" <roddomi@hotmail.com> writes:
> I am reading about position independent code (PIC). PIC is used mainly in
> shared libraries because they can be mapped to different parts of the
> address space in different processes. I am trying to trigger this behavior
> (to have a shared library that is mapped to different addresses in two
> different processes). To find out the actual mapping of the library I am
> using 'cat proc/<id>/maps'. However, I haven't been able to see this
> behavior. Does anybody have an example of how to trigger it? I am running
> this experiment on an x86-linux machine.
Many modern GNU/Linux systems use prelinking, which adjusts the shared
libraries so that they will be more efficient when loaded at a
specific address. For more details: "man prelink". If your shared
libraries are prelinked, then they will normally be loaded at the same
location.
The easiest way to see this happen is to write a program which uses
dlopen of shared libraries. If you dlopen them in a different order
you will most likely see them at different addresses.
Ian