HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 75 (of 101)
Chapter 11 Software Development
October 29, 2013
Exec Format Error
/usr/lib/dld.sl: Bad magic number for shared library: ./libmylib.sl
/usr/lib/dld.sl: Exec format error
Abort(coredump)
/usr/lib/dld.sl: Bad system id for shared library: ./libx.sl
/usr/lib/dld.sl: Exec format error
ABORT instruction (core dumped)
These or similar errors messages appear if the dynamic loader tries to load a shared library of an
executable format which is incompatible either to the executable or to the hardware. Possible
causes are loading a 64-bit library to a 32-bit executable or vice versa, or loading a PA2.0 shared
library to a PA1.1 executable on a PA1.1 system. To resolve this, check the file type of the
library listed in the error message, and if a library with the same name exists in a different
directory, which might be the right one to use. Then change the library search paths accordingly.
Thread Local Storage
/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local
Storage: /usr/lib/libcl.2
/usr/lib/dld.sl: Exec format error
This error can occur when an already running program executes a call to shl_load(3X) or
dlopen(3C) to load a shared library, which itself contains thread local storage (TLS), or one of
its dependent libraries from the shared library list does. This type of dynamic loading of a library
with TLS is not possible, as such libraries can only be loaded by dld.sl at program startup.
This problem has frequently been observed with perl modules that require libcl and/or
libpthread, which both contain TLS. There have been perl versions out there which are not
linked against both. That’s why loading such perl modules will fail with the above error.
A quick way to resolve this problem is to add all required libraries, separated by semi-colons,
that contain TLS into the env var LD_PRELOAD. But the correct solution would be to link these
libraries directly to the executable. In both cases, the libs will be loaded at program startup, and
if later the program code tries to load these libs, they don’t need to be loaded again.
In the case of perl, you can either relink it with -lcl -lpthread (you can because it is open
source), or use the supported perl version which should already be linked properly. If neither is
possible, use LD_PRELOAD to load these libraries when perl is started:
LD_PRELOAD=/usr/lib/libcl.2:/usr/lib/libpthread.1 perl <options>