pa-risc & dlopen for 32-bit (166 Views)
Reply
Occasional Contributor
Kercan
Posts: 6
Registered: ‎12-22-2005
Message 1 of 4 (166 Views)

pa-risc & dlopen for 32-bit

I'm trying to open a shared lib on a pa-risc system like this:

dlhdl = dlopen("libmydll.sl",RTLD_LAZY|RTLD_GLOBAL);
printf("%s\n",dlerror());

When the DLL & app are compiled as 32-bit this always fails - with an error saying that the it cannot open the shared lib libmydll.sl ...

However it works when I compile both the DLL & app as 64-bit (+DD64).

Is there any additional settings to get dlopen to work in 32-bit mode

(all the env settings are the same when I try the tests i.e. SHLIB_PATH, LD_LIBRARY_PATH etc are all the same)
Acclaimed Contributor
Dennis Handly
Posts: 25,067
Registered: ‎03-06-2006
Message 2 of 4 (166 Views)

Re: pa-risc & dlopen for 32-bit

If you expect to use SHLIB_PATH with the SOM dld.sl, you must link with -Wl,+s. Or use "chatr +s enable executable".
Occasional Contributor
Kercan
Posts: 6
Registered: ‎12-22-2005
Message 3 of 4 (166 Views)

Re: pa-risc & dlopen for 32-bit

the chatr seems to work. Now its a different issue. My shared library is built with "-mt" (linked with pthreads).

So when I do a dlopen/shl_load of this library I get:
/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /usr/lib/libpthread.1

The documentation seems to suggest that I can compile my shared library with the +tls=dynamic option and I should'nt see this anymore ... however that does not seem to work. I still get the same error messsage.

By the way the versions I have is:
aCC: HP ANSI C++ B3910B A.03.60
HPUX B.11.11 U 9000/800


(exporting LD_PRELOAD does solve the problem - but I'd like to be able to resolve it without having users do this)

Thanks
Acclaimed Contributor
Dennis Handly
Posts: 25,067
Registered: ‎03-06-2006
Message 4 of 4 (166 Views)

Re: pa-risc & dlopen for 32-bit

>"-mt" (linked with pthreads).

You shouldn't link shlibs with libpthread. -mt has been fixed to no longer do that with -b. Only the executable should be linked with libpthread.

>I can compile my shared library with the +tls=dynamic option and I shouldn't see this anymore

That only works for your shlib, not for libpthread. And +tls=dynamic doesn't work for PA.

>exporting LD_PRELOAD does solve the problem

As I mentioned, if you are actually creating threads, then link your executables with libpthread.

If you aren't creating threads, then don't link your shlibs with -mt.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.