dlfcn.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* User functions for run-time dynamic loading.
  2. Copyright (C) 1995-1999,2000,2001,2003,2004 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _DLFCN_H
  17. #define _DLFCN_H 1
  18. #include <features.h>
  19. #define __need_size_t
  20. #include <stddef.h>
  21. /* Collect various system dependent definitions and declarations. */
  22. #include <bits/dlfcn.h>
  23. #ifdef __USE_GNU
  24. /* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
  25. the run-time address of the symbol called NAME in the next shared
  26. object is returned. The "next" relation is defined by the order
  27. the shared objects were loaded. */
  28. # define RTLD_NEXT ((void *) -1l)
  29. /* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
  30. the run-time address of the symbol called NAME in the global scope
  31. is returned. */
  32. # define RTLD_DEFAULT ((void *) 0)
  33. #endif
  34. __BEGIN_DECLS
  35. /* Open the shared object FILE and map it in; return a handle that can be
  36. passed to `dlsym' to get symbol values from it. */
  37. extern void *dlopen (__const char *__file, int __mode) __THROW;
  38. /* Unmap and close a shared object opened by `dlopen'.
  39. The handle cannot be used again after calling `dlclose'. */
  40. extern int dlclose (void *__handle) __THROW __nonnull ((1));
  41. /* Find the run-time address in the shared object HANDLE refers to
  42. of the symbol called NAME. */
  43. extern void *dlsym (void *__restrict __handle,
  44. __const char *__restrict __name) __THROW __nonnull ((2));
  45. #if 0
  46. #ifdef __USE_GNU
  47. /* Find the run-time address in the shared object HANDLE refers to
  48. of the symbol called NAME with VERSION. */
  49. extern void *dlvsym (void *__restrict __handle,
  50. __const char *__restrict __name,
  51. __const char *__restrict __version)
  52. __THROW __nonnull ((2, 3));
  53. #endif
  54. #endif
  55. /* When any of the above functions fails, call this function
  56. to return a string describing the error. Each call resets
  57. the error string so that a following call returns null. */
  58. extern char *dlerror (void) __THROW;
  59. #ifdef __USE_GNU
  60. /* Structure containing information about object searched using
  61. `dladdr'. */
  62. typedef struct
  63. {
  64. __const char *dli_fname; /* File name of defining object. */
  65. void *dli_fbase; /* Load address of that object. */
  66. __const char *dli_sname; /* Name of nearest symbol. */
  67. void *dli_saddr; /* Exact value of nearest symbol. */
  68. } Dl_info;
  69. /* Fill in *INFO with the following information about ADDRESS.
  70. Returns 0 iff no shared object's segments contain that address. */
  71. extern int dladdr (__const void *__address, Dl_info *__info)
  72. __THROW __nonnull ((2));
  73. /* Get information about the shared objects currently loaded */
  74. extern int dlinfo (void);
  75. #endif
  76. __END_DECLS
  77. #endif /* dlfcn.h */