Why do I have to use LD_PRELOAD for libcl.2 to use XML::LibXML::Common on HP/UX?

江枫思渺然 提交于 2019-12-11 03:22:02

问题


A compulsion of LD_PRELOAD on HP platform only and not on other unix flavors (AIX,Linux, and Solaris).

I built Perl Module XML::LibXML::Common on all of Unix flavors.I had to specifically do LD_PRELOAD for libcl.2 library on HP Platform only. While on other unix platforms nothing as such was required.

Is this an OS behaviour or something really missing in HP loader/compiler?

I was running a perl script which simply creates a new object of "XML::LibXML::SAX"

use XML::LibXML::SAX;
$x = XML::LibXML::SAX->new();

and it complained for

Can't load 'site_perl/5.8.8/PA-RISC2.0-thread-multi/auto/XML/LibXML/Common/Common.sl' for module XML::LibXML::Common: Exec format error

and when i do the LD_PRELOAD for libcl.2 the error goes away and the Perl is built for a multi threaded support.


回答1:


I think you are asking why you have to use it. If you are running Perl multi-threaded one of the libraries you are calling is getting loaded before libc and it is likely single threaded. As part of its dependency processing, it is attempting to load a multi-threaded library in your environment. By using LD_PRELOAD I think you are using the principle of library interposition to force that library to load prior to loading the unsafe library. The notion of interposition is a complex one and you might gain some benefit from the following link:

Excerpt:

To use library interposition, you need to create a special shared library and set the LD_PRELOAD environment variable. When LD_PRELOAD is set, the dynamic linker will use the specified library before any other when it searches for shared libraries.




回答2:


Your question isn't clear...why did you have to use LD_PRELOAD?

Is it because HP-UX uses SHLIB_PATH instead of LD_LIBRARY_PATH, so you were setting the wrong environment variable?

It has other spellings on other platforms, too - Solaris and Linux happen to share much the same set of env. vars. MacOS X uses DYLIB_LIBRARY_PATH; AIX uses use LIBPATH, I believe.




回答3:


Though this is an old subject, I'm seeing something similar on HP-UX right now. In my case, it's not Perl, but while building Python's sqlite3 binding, dynamic loading of /usr/lib/libcl.2 is failing.

I've run the configure script with --with-libs='-lcl'. Though linking it to the binary and using LD_PRELOAD is not the same, both changes when /usr/lib/libcl.2 is loaded. Since it solved mine, try that.




回答4:


I'm not sure if this is relevant, but it probably is. THe Perl included with HP-UX is not the standard Perl but is a copy of ActiveState Perl - along with whatever strangeness that might include. If you find Perl acting strangely on HP-UX in contrast to every other environment - check whether ActiveState Perl is at fault.



来源:https://stackoverflow.com/questions/752573/why-do-i-have-to-use-ld-preload-for-libcl-2-to-use-xmllibxmlcommon-on-hp-ux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!