Good afternoon,
I am having difficulties with libxml2.
I tried to build the Perl module XML-LibXML which is part of our standard runtime environment. However, this time the installation on a RHEL5 box failed, because the build process complained about missing libxml2:
$> perl Makefile.PL LIB=/foo/lib/perl PREFIX=/foo INSTALLDIRS=site enable native perl UTF8 running xml2-config...ok (2.7.6) looking for -lxml2... no looking for -llibxml2... no libxml2 not found
However, the file was available. Starting the build with
perl Makefile.PL LIB=/usr/inform/target/lib/perl PREFIX=/usr/inform/target INSTALLDIRS=site
led to more evidence of the real problem:
[...] Can't load 'blib/arch/auto/Conftest/Conftest.so' for module Conftest: /usr/inform/target/lib/libxml2.so.2: cannot restore segment prot after reloc: Permission denied at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm line 230. at test.pl line 2 [...]
After some investigations I found that the problem appears to be that libxml2.so
is created with text relocation:
[tess91@INF-AW] lib$ eu-findtextrel libxml2.so.2.7.6 the file containing the function 'get_crc_table' is not compiled with -fpic/-fPIC the file containing the function 'crc32' is not compiled with -fpic/-fPIC the file containing the function 'gzerror' is not compiled with -fpic/-fPIC [...]
Ans since we have SElinux active on the target machine, linking against libxml.2 failed!
Is there any possibility to create libxml2
properly, or do I have to ask the admin to twist SElinux to allow relocations?
I really can't believe I am the olny one having this problem on Linux with SElinux active. What am I missing?
Any help apprecitated!
Regards, Stefan
The simplest way is to have your administrator yum install libxml2-devel
or even yum install perl-XML-LibXML
. Otherwise, see if you can add -fPIC
to the CFLAGS in the Makefile.PL
.
I assume you are on 32-bit x86, any other architecture wouldn't work without -fPIC
.
I just found a possible explanation:
During the build of libxml2 the compiler flag -fPIC is indeed used, so the code is created position independant, BUT :
When creating the shared library, the static libz is linked against it. Is that the source of my problem? That including a static lib in a shared executable taints the library by introducing non-relocatable code?
The fact that the symbols eu-findtextrel should already have pointed me in that direction, since crc32
, get_crc_table
, etc. look like encryption centered code...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.