Subject: Re: IPSEC in GENERIC
To: Andrew Reilly <andrew-netbsd@areilly.bpc-users.org>
From: Richard Earnshaw <Richard.Earnshaw@buzzard.freeserve.co.uk>
List: tech-kern
Date: 02/22/2006 09:27:01
On Wed, 22 Feb 2006 17:40:19 +1100, Andrew Reilly wrote:
> On Mon, Feb 20, 2006 at 07:50:22AM -0800, Garrett D'Amore wrote:
> > if you don't have -fPIC (or at least -fpic), how do you get them to be
> > loadable?  You have to be able to change the addresses, right?  Or am I
> > missing something obvious?
> 
> Shared libraries have to be position independent so that the same
> text image can be mapped into different processes at different
> addresses.  LKMs are only mapped once, into the kernel's address
> space, so a static linking at load time gets the job done.

While true however, there are other issues to consider.  Typical BSD/SVR4 
style shared libraries generally only have a very small number of 
relocation types, since only data is relocated (probably of the order of 
half a dozen), but non-pic object files may potentially have a very large 
number (for example, the ARM EABI defines about 100, possibly half of 
which might appear in a normal loadable object).  This is particularly the 
case on RISC processors where relocation of various immediate fields in 
different instructions is necessary.  So restricting yourself to having 
only PIC code in LKMs might make linking a significantly less complex 
process.

R.