简体   繁体   English

有没有办法在Linux上构建没有文本重定位的libxml2?

[英]Is there a way to build a libxml2 without text relocations on Linux?

Good afternoon, 下午好,

I am having difficulties with libxml2. 我在使用libxml2时遇到困难。

I tried to build the Perl module XML-LibXML which is part of our standard runtime environment. 我试图构建Perl模块XML-LibXML,这是我们标准运行时环境的一部分。 However, this time the installation on a RHEL5 box failed, because the build process complained about missing libxml2: 但是,这一次在RHEL5机器上的安装失败,因为构建过程抱怨缺少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: 经过一些调查后,我发现问题似乎是使用文本重定位创建了libxml2.so

[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! 回答:既然我们在目标计算机上激活了SElinux,那么针对libxml.2的链接失败!

Is there any possibility to create libxml2 properly, or do I have to ask the admin to twist SElinux to allow relocations? 是否有可能正确创建libxml2 ,还是我必须要求管理员扭转SElinux以允许重定位?

I really can't believe I am the olny one having this problem on Linux with SElinux active. 我真的不敢相信我是在激活SElinux的Linux上遇到此问题的唯一人。 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 . 最简单的方法是让管理员yum install libxml2-devel甚至yum install perl-XML-LibXML Otherwise, see if you can add -fPIC to the CFLAGS in the Makefile.PL . 否则,请查看是否可以在Makefile.PL中将-fPIC添加到CFLAGS中。

I assume you are on 32-bit x86, any other architecture wouldn't work without -fPIC . 我假设您使用的是32位x86,没有-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 : 在构建libxml2的过程中,确实使用了编译器标志-fPIC,因此将代码创建为位置无关的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... 符号eu-findtextrel应该已经向我指出了这一事实,因为crc32get_crc_table等看起来像是以加密为中心的代码...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM