Subject: -fPIC: any problems to be expected?
To: None <tech-toolchain@NetBSD.ORG>
From: Ignatios Souvatzis <is@jocelyn.rhein.de>
List: tech-toolchain
Date: 07/28/1998 20:47:47
Hello,

I noticed that bsd.lib.mk sets -fpic for most architectures.

While this might create slightly faster, slightly smaller code for shared 
libraries and shared library access, this code will break as soon as some
executable contains enough "shared" external accesses to overflow the global
offset table (basically, you jump to a wrong GOT slot and get a SEGV if you
are lucky... or call the wrong function causing worse things).

[I've seen this with xfig on m68k last week]

So, normally, general-use libraries should always be created with -fPIC, which
allows (hopefully) for the biggest possible GOT. [Obviously, architectures 
were both are equivalent won't be touched by this discussion]

Now, I think I remember some message that claims that mixing -fpic and -fPIC 
doesn't work on some architectures (was it sparc?), but I can't find it.

If this is the case, the transition to -fPIC must be done very carefully, 
to prevent losing your toolchain if something goes wrong...

If somebody can enlighten me about possible problems on some architectures,
please do so.

Regards,
	Ignatios Souvatzis