Blame dlfcn/dlfcn.h

Packit 6c4009
/* User functions for run-time dynamic loading.
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef	_DLFCN_H
Packit 6c4009
#define	_DLFCN_H 1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
#define __need_size_t
Packit 6c4009
#include <stddef.h>
Packit 6c4009
Packit 6c4009
/* Collect various system dependent definitions and declarations.  */
Packit 6c4009
#include <bits/dlfcn.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
Packit 6c4009
   the run-time address of the symbol called NAME in the next shared
Packit 6c4009
   object is returned.  The "next" relation is defined by the order
Packit 6c4009
   the shared objects were loaded.  */
Packit 6c4009
# define RTLD_NEXT	((void *) -1l)
Packit 6c4009
Packit 6c4009
/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
Packit 6c4009
   the run-time address of the symbol called NAME in the global scope
Packit 6c4009
   is returned.  */
Packit 6c4009
# define RTLD_DEFAULT	((void *) 0)
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Type for namespace indeces.  */
Packit 6c4009
typedef long int Lmid_t;
Packit 6c4009
Packit 6c4009
/* Special namespace ID values.  */
Packit 6c4009
# define LM_ID_BASE	0	/* Initial namespace.  */
Packit 6c4009
# define LM_ID_NEWLM	-1	/* For dlmopen: request new namespace.  */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Open the shared object FILE and map it in; return a handle that can be
Packit 6c4009
   passed to `dlsym' to get symbol values from it.  */
Packit 6c4009
extern void *dlopen (const char *__file, int __mode) __THROWNL;
Packit 6c4009
Packit 6c4009
/* Unmap and close a shared object opened by `dlopen'.
Packit 6c4009
   The handle cannot be used again after calling `dlclose'.  */
Packit 6c4009
extern int dlclose (void *__handle) __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Find the run-time address in the shared object HANDLE refers to
Packit 6c4009
   of the symbol called NAME.  */
Packit 6c4009
extern void *dlsym (void *__restrict __handle,
Packit 6c4009
		    const char *__restrict __name) __THROW __nonnull ((2));
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* Like `dlopen', but request object to be allocated in a new namespace.  */
Packit 6c4009
extern void *dlmopen (Lmid_t __nsid, const char *__file, int __mode) __THROWNL;
Packit 6c4009
Packit 6c4009
/* Find the run-time address in the shared object HANDLE refers to
Packit 6c4009
   of the symbol called NAME with VERSION.  */
Packit 6c4009
extern void *dlvsym (void *__restrict __handle,
Packit 6c4009
		     const char *__restrict __name,
Packit 6c4009
		     const char *__restrict __version)
Packit 6c4009
     __THROW __nonnull ((2, 3));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* When any of the above functions fails, call this function
Packit 6c4009
   to return a string describing the error.  Each call resets
Packit 6c4009
   the error string so that a following call returns null.  */
Packit 6c4009
extern char *dlerror (void) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* Structure containing information about object searched using
Packit 6c4009
   `dladdr'.  */
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  const char *dli_fname;	/* File name of defining object.  */
Packit 6c4009
  void *dli_fbase;		/* Load address of that object.  */
Packit 6c4009
  const char *dli_sname;	/* Name of nearest symbol.  */
Packit 6c4009
  void *dli_saddr;		/* Exact value of nearest symbol.  */
Packit 6c4009
} Dl_info;
Packit 6c4009
Packit 6c4009
/* Fill in *INFO with the following information about ADDRESS.
Packit 6c4009
   Returns 0 iff no shared object's segments contain that address.  */
Packit 6c4009
extern int dladdr (const void *__address, Dl_info *__info)
Packit 6c4009
     __THROW __nonnull ((2));
Packit 6c4009
Packit 6c4009
/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS.  */
Packit 6c4009
extern int dladdr1 (const void *__address, Dl_info *__info,
Packit 6c4009
		    void **__extra_info, int __flags) __THROW __nonnull ((2));
Packit 6c4009
Packit 6c4009
/* These are the possible values for the FLAGS argument to `dladdr1'.
Packit 6c4009
   This indicates what extra information is stored at *EXTRA_INFO.
Packit 6c4009
   It may also be zero, in which case the EXTRA_INFO argument is not used.  */
Packit 6c4009
enum
Packit 6c4009
  {
Packit 6c4009
    /* Matching symbol table entry (const ElfNN_Sym *).  */
Packit 6c4009
    RTLD_DL_SYMENT = 1,
Packit 6c4009
Packit 6c4009
    /* The object containing the address (struct link_map *).  */
Packit 6c4009
    RTLD_DL_LINKMAP = 2
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Get information about the shared object HANDLE refers to.
Packit 6c4009
   REQUEST is from among the values below, and determines the use of ARG.
Packit 6c4009
Packit 6c4009
   On success, returns zero.  On failure, returns -1 and records an error
Packit 6c4009
   message to be fetched with `dlerror'.  */
Packit 6c4009
extern int dlinfo (void *__restrict __handle,
Packit 6c4009
		   int __request, void *__restrict __arg)
Packit 6c4009
     __THROW __nonnull ((1, 3));
Packit 6c4009
Packit 6c4009
/* These are the possible values for the REQUEST argument to `dlinfo'.  */
Packit 6c4009
enum
Packit 6c4009
  {
Packit 6c4009
    /* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there.  */
Packit 6c4009
    RTLD_DI_LMID = 1,
Packit 6c4009
Packit 6c4009
    /* Treat ARG as `struct link_map **';
Packit 6c4009
       store the `struct link_map *' for HANDLE there.  */
Packit 6c4009
    RTLD_DI_LINKMAP = 2,
Packit 6c4009
Packit 6c4009
    RTLD_DI_CONFIGADDR = 3,	/* Unsupported, defined by Solaris.  */
Packit 6c4009
Packit 6c4009
    /* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the
Packit 6c4009
       directories that will be searched for dependencies of this object.
Packit 6c4009
       RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size'
Packit 6c4009
       entries to indicate the size of the buffer that must be passed to
Packit 6c4009
       RTLD_DI_SERINFO to fill in the full information.  */
Packit 6c4009
    RTLD_DI_SERINFO = 4,
Packit 6c4009
    RTLD_DI_SERINFOSIZE = 5,
Packit 6c4009
Packit 6c4009
    /* Treat ARG as `char *', and store there the directory name used to
Packit 6c4009
       expand $ORIGIN in this shared object's dependency file names.  */
Packit 6c4009
    RTLD_DI_ORIGIN = 6,
Packit 6c4009
Packit 6c4009
    RTLD_DI_PROFILENAME = 7,	/* Unsupported, defined by Solaris.  */
Packit 6c4009
    RTLD_DI_PROFILEOUT = 8,	/* Unsupported, defined by Solaris.  */
Packit 6c4009
Packit 6c4009
    /* Treat ARG as `size_t *', and store there the TLS module ID
Packit 6c4009
       of this object's PT_TLS segment, as used in TLS relocations;
Packit 6c4009
       store zero if this object does not define a PT_TLS segment.  */
Packit 6c4009
    RTLD_DI_TLS_MODID = 9,
Packit 6c4009
Packit 6c4009
    /* Treat ARG as `void **', and store there a pointer to the calling
Packit 6c4009
       thread's TLS block corresponding to this object's PT_TLS segment.
Packit 6c4009
       Store a null pointer if this object does not define a PT_TLS
Packit 6c4009
       segment, or if the calling thread has not allocated a block for it.  */
Packit 6c4009
    RTLD_DI_TLS_DATA = 10,
Packit 6c4009
Packit 6c4009
    RTLD_DI_MAX = 10
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* This is the type of elements in `Dl_serinfo', below.
Packit 6c4009
   The `dls_name' member points to space in the buffer passed to `dlinfo'.  */
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  char *dls_name;		/* Name of library search path directory.  */
Packit 6c4009
  unsigned int dls_flags;	/* Indicates where this directory came from. */
Packit 6c4009
} Dl_serpath;
Packit 6c4009
Packit 6c4009
/* This is the structure that must be passed (by reference) to `dlinfo' for
Packit 6c4009
   the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests.  */
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  size_t dls_size;		/* Size in bytes of the whole buffer.  */
Packit 6c4009
  unsigned int dls_cnt;		/* Number of elements in `dls_serpath'.  */
Packit 6c4009
  Dl_serpath dls_serpath[1];	/* Actually longer, dls_cnt elements.  */
Packit 6c4009
} Dl_serinfo;
Packit 6c4009
#endif /* __USE_GNU */
Packit 6c4009
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif	/* dlfcn.h */