Re: do we need -fPIC for X11R6 modules


Subject: Re: do we need -fPIC for X11R6 modules
From: David Brown (linux-kernel@davidb.org)
Date: Mon Oct 08 2001 - 23:55:50 MDT


On Mon, Oct 08, 2001 at 08:54:57PM -0400, Kevin B. Hendricks wrote:

> What exactly are X11R6 modules? Are they shared libraries? If so, they
> should be built using -fPIC? If they are not shared libraries, how are
> they "loaded" and "linked" in?
>
> If they are "loaded and linked" into a normal shared library, then -fPIC
> should be used anyway.
>
> I guess I don't understand how a load-on-demand module can be created
> without -fPIC.

-fPIC is never "needed" for a load-on-demand module. The dynamic linker
always always fixes up symbols when loading objects. What -fPIC does is
isolate the pieces of the code that need to be adjusted to a small part of
the library, so that the rest of the code can be shared. For a library
that is shared by multiple applications, this significantly reduces the
memory usage of these executables, since they share much code.

However, -fPIC is not without cost. The position independent code has to
make any external references through the small sections. This often
amounts to an extra indirection, or an extra jump on calls. It certainly
would not be wanted by an object that was only loaded by a single
program.

Dave Brown



This archive was generated by hypermail 2a24 : Mon Oct 08 2001 - 23:07:30 MDT