[fpc-pascal] Text relocation in x86 binary lib

Jonas Maebe jonas.maebe at elis.ugent.be
Mon May 31 14:31:19 CEST 2010


On 31 May 2010, at 14:23, Matthias Klumpp wrote:

> A quick check which eu-findtextrels found a lot of those in the lib.
> Exactly the same code compiled for 64bit does not contain any text
> relocation.
> How can this happen?

It's because we don't generate PIC (position-independent code) by  
default on Linux-i386, because
a) PIC is fairly inefficient on i386 (it requires an extra register,  
and the i386 is already register-starved as it is -- on average, it  
results in a 10% performance degradation)
b) very few people use SELinux, and on non-SELinux systems dynamic  
libraries without PIC work fine (with a small memory usage penalty,  
because the code cannot be shared amongst multiple processes)

On x86-64, there is almost no penalty for PIC vs no PIC.

You have to recompile the entire RTL and your own code with the -Cg  
compiler option to get shared libraries that only contain PIC.


Jonas



More information about the fpc-pascal mailing list