Multithread Usage

This routine is thread-safe. Calls to dlsetlibpath affect all subsequent calls to dlopen, dlopene, and dlgetfileinfo on any thread.

See also dlopen(3C), dlopene(3C), dlgetfileinfo(3C), dlerror(3C), dlerrno(3C), dld.so(5).

Return Value

If successful, dlsetlibpath returns 0, otherwise a non-0 value is returned. More detailed diagnostic information is available through dlerror or dlerrno.

Errors

If dlsetlibpath fails, a subsequent call to dlerrno returns one of the following values:

RTLD_ERR_NO_MEMORY - Cannot allocate dynamic memory.

RTLD_ERR_CANT_APPLY_RELOC - Failed to apply relocation while resolving call to dlsetlibpath. RTLD_ERR_SIGINHIBIT_FAILED - The siginhibit call failed on entry to dlsetlibpath . RTLD_ERR_SIGENABLE_FAILED - The sigenable call failed on exit from dlsetlibpath. RTLD_ERR_SETCANCELSTATE_FAILED - __thread_setcancelstate failed on entry to or exit from dlsetlibpath. RTLD_ERR_INV_DLSETLIBPATH_ARGUMENT - Invalid argument in call to dlsetlibpath.

The dlerrno Routine

The dlerrno routine returns a numeric error code that corresponds to the last error that occurred during dynamic linking processing.

Synopsis

cc[flag ... ] file ... -ldl [library] ...

#include <dlfcn.h> int *dlerrno(void);

Description

The dlerrno routine is one of a family of routines that give the user direct access to the dynamic linking facilities (using the -ldloption on the compiler or ld command line). The dlerrno routine returns a numeric error code that corresponds to the last error that occurred during dynamic linking processing. If no dynamic linking errors have occurred since the last invocation of dlerrno, dlerrno returns RTLD_ERR_NO_ERR (-1). Thus, invoking dlerrno a second time, immediately following a prior invocation, returns RTLD_ERR_NO_ERR (-1). For a complete list of the mnemonic error codes, see the dlerrno(3C) manpage.

The dlgetfileinfo Routine

The dlgetfileinfo routine returns file information for a library prior to loading it.

Synopsis

cc[flag ... ] file ... -ldl [library] ...

#include <dlfcn.h>

uint64_t dlgetfileinfo(const char *file,

size_t info_size,

struct dlfileinfo *info);

Description

The dlgetfileinfo routine is one of a family of routines that give the user direct access to the dynamic linking facilities (using the -ldloption on the compiler or ld command line). dlgetfileinfo returns file information for a library prior to loading it. This information can be used to allocate load segments before calling dlopene.

The file is used to construct a pathname to the library. The dynamic loader searches for the library using the standard search rules used by dlopen and dlopene. If the library is found and is a

The dlopen Shared Library Management Routines 155

Page 155
Image 155
HP UX Software Transition Kit (STK) manual Dlerrno Routine, Dlgetfileinfo Routine, Multithread Usage, Return Value, Errors