Operating System - HP-UX
1835667 Members
3014 Online
110082 Solutions
New Discussion

shl_load returns errno 22

 
ArieMo
Occasional Advisor

shl_load returns errno 22

The following line of C-code returns the errno 22:
shl_load(dllname,BIND_DEFERRED|DYNAMIC_PATH, )l);

The dllname is the name of a shared library, which can be found by the program (file permissions are ok). This was working before we converted to a Trusted System (OS = HP-UX 11.00).
What part of the arguments used can be invalid?

Thanks.
3 REPLIES 3
Steve Steel
Honored Contributor

Re: shl_load returns errno 22

Hi

Rebuild with LD_PRELOAD


I can guess that you need the latest linker patch and then use the LD_PRELOAD functionality to avoide this

You can use the LD_PRELOAD environment variable to load a shared library that contains thread-local storage to avoid the following error when loading the library dynamically:

/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /usr/lib/libpthread.1

Also error 22

The load order and symbol resolution order may be different in a PA32 program than in the same PA64 program because the dynamic loader uses depth-first search order in PA32 mode and breadth-first search order in PA64 mode.
The dynamic loader uses the LD_PRELOAD environment variable even if you use the +noenvvar in the link line. This insures that LD_PRELOAD is enabled even in a +compat link. The LD_PRELOAD variable is always enabled except for setuid and setgid programs.

Note: Using LD_PRELOAD can cause a core dump when used with applications which mix shared and archived libraries, especially when both the shared library and the application are built with aC++ or use libc.

You can specify multiple libraries as part of the LD_PRELOAD environment variable. Separate the libraries by spaces or colons as in LD_LIBRARY_PATH. (Multi-byte support is not provided as part of parsing the LD_PRELOAD library list). You can specify LD_PRELOAD libraries with absolute paths or relative paths. The LD_PRELOAD libraries can also consist of just the library names, in which case the dynamic loader uses the directory path list in the environment variables LD_LIBRARY_PATH and/or SHLIB_PATH or the embedded path list (if enabled) to search for the libraries.

The dynamic loader does not issue an error or warning message if it cannot find a library specified by LD_PRELOAD. However, if it does not find a dependent of the LD_PRELOAD libraries, the dynamic loader issues the same error message as if the LD_PRELOAD library is specified in the link line.



See man dld.sl when patch is loaded


Steve steel
If you want truly to understand something, try to change it. (Kurt Lewin)
ArieMo
Occasional Advisor

Re: shl_load returns errno 22

Hi

I don't get the /usr/lib/dld.sl error. I explicit do a printf of errno after the shl_load routine to see why the program doesn't work. I've download the latest ld patch now and will try it again after applying it.

Thanks.
ArieMo
Occasional Advisor

Re: shl_load returns errno 22

Changing the order of the libraries in the make file solved the problem:

Specifying -lc before -lpthread in threaded applications can cause run-time problems because the pthread/cma stubs are resolved instead of the real pthread/cma functions.

Also using LD_PRELOAD='/usr/lib/libpthread.1' worked.

Thanks for the suggestions.