dlgetfileinfo man page on HP-UX

Man page or keyword search:  
man Server   10987 pages
apropos Keyword Search (all sections)
Output format
HP-UX logo
[printable version]

dlgetfileinfo(3C)					     dlgetfileinfo(3C)

NAME
       dlgetfileinfo()	- return file information for a library prior to load‐
       ing it

SYNOPSIS
       [flag... ] file...  [library]...

       uint64_t dlgetfileinfo(const char *file,
			      size_t info_size,
			      struct dlfileinfo *info);

   Multithread Usage
       This routine is thread-safe.

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

       file  is	 used  to  construct  a path name to the library.  The dynamic
       loader searches for the library using the standard search rules used by
       and  If	the  library  is  found and is a valid shared library, returns
       information about the library through the info parameter.

       info_size is the size in bytes of the info buffer.

       info is a pointer to a buffer  allocated	 by  the  user	program.   The
       dynamic loader fills this buffer with file information.

       A dlfileinfo structure has the following members:

	      struct dlfileinfo {
		 size_t text_size;
		 size_t data_size;
		 char *filename;
	      }

       text_size is the size in bytes of a shared library's text segment.

       data_size is the size in bytes of a shared library's data segment.

       filename is the path to the shared library.  This path may be passed to
       a subsequent or call to avoid searching for the library a second	 time.
       The  caller of must copy the value of filename to insure that it is not
       corrupted.

EXAMPLES
       The following example illustrates the use of  to	 allocate  memory  for
       mapping	a shared library's data segment.  For simplicity, error check‐
       ing has been omitted.

	     #include <dlfcn.h>
	     #include <string.h>

	     /* allocate_data is a user-supplied routine that allocates a
	      * a memory buffer of at least "data_size" bytes and returns
	      * a pointer to the buffer.
	      */
	     extern char *allocate_data(size_t data_size);

	     int main() {
		 void	*handle;
		 int	status;
		 char	*pathname;
		 struct dlfileinfo  info;
		 struct dlopen_opts opts;

		 /* Locate library and get file information */
		 status = dlgetfileinfo("mylib.so", sizeof(info), &info);

		 if (status == 0) {

		     /* Make a copy of the library pathname returned by
		      * dlgetfileinfo().
		      */
		     pathname = strdup(info.filename);

		     /* Allocate data segment */
		     opts.data_addr = allocate_data(info.data_size);

		     /* Not preallocating text segment */
		     opts.text_addr = 0;

		     /* Set dlopene() flags to indicate the data segment
		      * has been preallocated.
		      */
		     opts.flags = RTLD_EXT_DATA_ADDR;

		     /* Call dlopene() to load the library using the path
		      * where dlgetfileinfo found the library and the
		      * preallocated memory buffer for mapping the library's
		      * data segment.
		      */
		     handle = dlopene(pathname, RTLD_LAZY, &opts);

		     /* Remove copy of library pathname */
		     free(pathname);

		     /* Insert code here to use library */

		     /* Close library */
		     status = dlclose(handle);

		     /* Insert code here to free storage allocated by
		      * allocate_data().
		      */
		 }
	     }

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

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

	      Unknown ELF version in library.

	      Unable to find library.

	      Cannot allocate dynamic memory.

	      Internal error encountered in

	      Failed to apply relocation while resolving call to

	      call failed on entry to

	      call failed on exit from

	      ABI  mismatch  because  a	 64-bit	 program found a 32-bit shared
	      library.

	      ABI mismatch because a 32-bit  program  found  a	64-bit	shared
	      library.

	      The library is invalid due to a bad magic number.

	      The library is invalid due to a bad machine type.

	      The library is invalid due to a bad object file type.

	      failed on entry to or exit from

	      Cannot return file information because the library has multiple
		     text segments.

	      Cannot return file information because the library has multiple
		     data segments.

	      Invalid argument in call to

	      An IO error occurred while reading the file information.

SEE ALSO
       dlerrno(3C), dlerror(3C), dlopen(3C), dlopene(3C), dlsetlibpath(3C).

   Texts and Tutorials:
       (See the		 option)
       (See		 manuals(5) for ordering information)

							     dlgetfileinfo(3C)
[top]

List of man pages available for HP-UX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net