[fpc-pascal] Linux i386 libraries and PIC

Ludo Brands ludo.brands at free.fr
Wed Jun 1 15:22:58 CEST 2011


Dear all,

I'm trying to create a library on linux i386 that contains only PIC code.
The library is a driver that runs unconfined causing SELinux (Fedora) to
block the loading of the library.
The library is compiled with -fPIC but eu-findtextrel reports a lot of
relocations (4933 in my library and 3852 in a small testlibrary). The
problem seems to be that the RTL isn't compiled with -fPIC. And that is
where I need your help. Here is what I tried so far  (fpc 2.5.1 svn 17622):
1) (bootstrap compiler 2.4.4)
make clean all OPT="-fPIC"
--> EAccessViolation when compiling system.pp with ppc386 (the bootstrap) 

2) (bootstrap compiler 2.5.1 build with make clean all)
make clean all OPT="-fPIC" PP=/path/to/2.5.1/compiler
--> EAccessViolation when compiling ../unix/classes with ppc1  

Compiler doesn't need to be PIC. So try rebuilding rtl only.

3) (fpc 2.4.4)
make clean all OPT="-g -gw" 
cd rtl  
make clean OPT="-fPIC -g -gw" 
--> EAccessViolation when compiling system.pp 

4) (still in dir rtl) 
make clean OPT="-fPIC -g -gw" PP=/path/to/2.5.1/compiler
cd ..
sudo make install 
--> changed checksum for system.pp, recompile cairo, can't find unit cairo

5) 
sudo make install OPT="-Fu/path/to/svn/packages/*/src/"
PP=/path/to/2.5.1/compiler
sudo make sourceinstall PP=/path/to/2.5.1/compiler

All OK. RTL should be PIC now. Rebuild testlibrary. Result from
eu-findtextrel 38: relocations for the testproject. Much, much better, but
not zero :(
Although the compiler (and the testproject) was build with -g -gw,
eu-findtextrel doesn't provide any usefull info on the relocation. It only
says "the file containing the function 'test' might not be compiled with
-fpic/-fPIC" for avery relocation found.
eu-readelf -r  shows 9692 386_relative and 4 386_JMP_SLOT type relocations. 

What did I do wrong? Or is a rtl PIC not enough?

BTW. Linux x64 works perfectly. 0 relocations and a happy SELinux.

Thanks, Ludo






More information about the fpc-pascal mailing list