[fpc-pascal] Linux i386 libraries and PIC

Ludo Brands ludo.brands at free.fr
Wed Jun 1 17:17:24 CEST 2011


Scanelf -qT gives more information:

libtestpic.so: (memory/data?) [0x241B7] in (optimized out: previous
_$SYSTEM$_Ld159) [0x241B4]
  libtestpic.so: (memory/data?) [0x24397] in (optimized out: previous
.La330) [0x24383]
  libtestpic.so: (memory/data?) [0x24577] in (optimized out: previous
.La337) [0x24555]
  libtestpic.so: (memory/data?) [0x35318] in (optimized out: previous
_$CLASSES$_Ld454) [0x350BE]
  libtestpic.so: (memory/data?) [0x48465] in (optimized out: previous .La29)
[0x4844C]
  libtestpic.so: (memory/data?) [0x6201E] in (optimized out: previous
SYSUTILS_FORMAT$ANSISTRING$array_of_const$$ANSISTRING) [0x62000]
  libtestpic.so: (memory/data?) [0x62168] in (optimized out: previous
SYSUTILS_FORMATBUF$formal$LONGWORD$formal$LONGWORD$array_of_const$$LONGWORD)
[0x62140]
  libtestpic.so: (memory/data?) [0x62261] in (optimized out: previous
SYSUTILS_FMTSTR$ANSISTRING$ANSISTRING$array_of_const) [0x62240]
  libtestpic.so: (memory/data?) [0x622A1] in (optimized out: previous
SYSUTILS_STRFMT$PCHAR$PCHAR$array_of_const$$PCHAR) [0x62280]
  libtestpic.so: (memory/data?) [0x62345] in (optimized out: previous
SYSUTILS_STRLFMT$PCHAR$LONGWORD$PCHAR$array_of_const$$PCHAR) [0x62320]
  libtestpic.so: (memory/data?) [0x626AE] in (optimized out: previous
DBG_BASEUNIX_TRLIMIT) [0x626A7]
  libtestpic.so: (memory/data?) [0x640EC] in (optimized out: previous
SYSUTILS_FLOATTOTEXT$PCHAR$EXTENDED$TFLOATFORMAT$LONGINT$LONGINT$$LONGINT)
[0x640C0]
  libtestpic.so: (memory/data?) [0x64179] in (optimized out: previous
SYSUTILS_FLOATTOSTRF$EXTENDED$TFLOATFORMAT$LONGINT$LONGINT$$ANSISTRING)
[0x64150]
  libtestpic.so: (memory/data?) [0x64204] in (optimized out: previous
SYSUTILS_FLOATTOSTRF$CURRENCY$TFLOATFORMAT$LONGINT$LONGINT$$ANSISTRING)
[0x641E0]
  libtestpic.so: (memory/data?) [0x642AE] in (optimized out: previous
SYSUTILS_FLOATTOSTRF$DOUBLE$TFLOATFORMAT$LONGINT$LONGINT$$ANSISTRING)
[0x64280]
  libtestpic.so: (memory/data?) [0x64341] in (optimized out: previous
SYSUTILS_FLOATTOSTRF$SINGLE$TFLOATFORMAT$LONGINT$LONGINT$$ANSISTRING)
[0x64320]
  libtestpic.so: (memory/data?) [0x643D4] in (optimized out: previous
SYSUTILS_FLOATTOSTRF$COMP$TFLOATFORMAT$LONGINT$LONGINT$$ANSISTRING)
[0x643B0]
  libtestpic.so: (memory/data?) [0x64474] in (optimized out: previous
SYSUTILS_FLOATTOSTRF$INT64$TFLOATFORMAT$LONGINT$LONGINT$$ANSISTRING)
[0x64450]
  libtestpic.so: (memory/data?) [0x68E78] in (optimized out: previous
SYSUTILS_STRTODATE$PCHAR$LONGINT$ANSISTRING$CHAR$$TDATETIME) [0x68E30]
  libtestpic.so: (memory/data?) [0x69995] in (optimized out: previous
SYSUTILS_STRTOTIME$PCHAR$LONGINT$CHAR$$TDATETIME) [0x69950]
  libtestpic.so: (memory/data?) [0x6AFC8] in (optimized out: previous
SYSUTILS_TRYSTRTODATE$SHORTSTRING$TDATETIME$ANSISTRING$CHAR$$BOOLEAN)
[0x6AF80]
  libtestpic.so: (memory/data?) [0x6B0A0] in (optimized out: previous
SYSUTILS_TRYSTRTODATE$ANSISTRING$TDATETIME$ANSISTRING$CHAR$$BOOLEAN)
[0x6B040]
  libtestpic.so: (memory/data?) [0x6B305] in (optimized out: previous
SYSUTILS_TRYSTRTOTIME$SHORTSTRING$TDATETIME$CHAR$$BOOLEAN) [0x6B2C0]
  libtestpic.so: (memory/data?) [0x6B40D] in (optimized out: previous
SYSUTILS_TRYSTRTOTIME$ANSISTRING$TDATETIME$CHAR$$BOOLEAN) [0x6B3B0]
  libtestpic.so: (memory/data?) [0x6E36E] in (optimized out: previous
SYSUTILS_WIDEFORMAT$WIDESTRING$array_of_const$$WIDESTRING) [0x6E350]
  libtestpic.so: (memory/data?) [0x6E4B8] in (optimized out: previous
SYSUTILS_WIDEFORMATBUF$formal$LONGWORD$formal$LONGWORD$array_of_const$$LONGW
ORD) [0x6E490]
  libtestpic.so: (memory/data?) [0x6E5B1] in (optimized out: previous
SYSUTILS_WIDEFMTSTR$WIDESTRING$WIDESTRING$array_of_const) [0x6E590]
  libtestpic.so: (memory/data?) [0x6FEFE] in (optimized out: previous
SYSUTILS_UNICODEFORMAT$UNICODESTRING$array_of_const$$UNICODESTRING)
[0x6FEE0]
  libtestpic.so: (memory/data?) [0x70048] in (optimized out: previous
SYSUTILS_UNICODEFORMATBUF$formal$LONGWORD$formal$LONGWORD$array_of_const$$LO
NGWORD) [0x70020]
  libtestpic.so: (memory/data?) [0x70141] in (optimized out: previous
SYSUTILS_UNICODEFMTSTR$UNICODESTRING$UNICODESTRING$array_of_const) [0x70120]
  libtestpic.so: (memory/data?) [0x7116B] in (optimized out: previous
SYSUTILS_SUPPORTS$IUNKNOWN$TCLASS$formal$$BOOLEAN) [0x71140]
  libtestpic.so: (memory/data?) [0x7BF23] in (optimized out: previous
UNIX_READTIMEZONEFILE$SHORTSTRING) [0x7BE50]
  libtestpic.so: (memory/data?) [0x7EC41] in (optimized out: previous
BASEUNIX_FPGETENV$SHORTSTRING$$PCHAR) [0x7EC10]
  libtestpic.so: (memory/data?) [0x80C64] in (optimized out: previous
BASEUNIX_FPOPEN$SHORTSTRING$LONGINT$$LONGINT) [0x80C30]
  libtestpic.so: (memory/data?) [0x80CD7] in (optimized out: previous
BASEUNIX_FPOPEN$SHORTSTRING$LONGINT$LONGWORD$$LONGINT) [0x80CA0]
  libtestpic.so: (memory/data?) [0x80DB1] in (optimized out: previous
BASEUNIX_FPOPENDIR$SHORTSTRING$$PDIR) [0x80D80]
  libtestpic.so: (memory/data?) [0x80E24] in (optimized out: previous
BASEUNIX_FPSTAT$SHORTSTRING$STAT$$LONGINT) [0x80DF0]
  libtestpic.so: (memory/data?) [0x8162C] in (optimized out: previous
UNIXUTIL_STRINGTOPPCHAR$SHORTSTRING$SMALLINT$$PPCHAR) [0x81610]
  libtestpic.so

AFAIK these are all part of the rtl. Why are only these remaining? 



> -----Message d'origine-----
> De : fpc-pascal-bounces at lists.freepascal.org 
> [mailto:fpc-pascal-bounces at lists.freepascal.org] De la part 
> de Ludo Brands
> Envoyé : mercredi 1 juin 2011 15:23
> À : 'FPC-Pascal users discussions'
> Objet : [fpc-pascal] Linux i386 libraries and PIC
> 
> 
> 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
> 
> 
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org 
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 




More information about the fpc-pascal mailing list