dlfcn.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* User functions for run-time dynamic loading.
  2. Copyright (C) 1995-1999, 2000 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 Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. 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. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #ifndef _DLFCN_H
  17. #define _DLFCN_H 1
  18. #include <features.h>
  19. /* Collect various system dependent definitions and declarations. */
  20. #include <bits/dlfcn.h>
  21. /* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
  22. the run-time address of the symbol called NAME in the next shared
  23. object is returned. The "next" relation is defined by the order
  24. the shared objects were loaded. */
  25. #define RTLD_NEXT ((void *) -1l)
  26. /* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
  27. the run-time address of the symbol called NAME in the global scope
  28. is returned. */
  29. #define RTLD_DEFAULT ((void *) 0)
  30. __BEGIN_DECLS
  31. /* Open the shared object FILE and map it in; return a handle that can be
  32. passed to `dlsym' to get symbol values from it. */
  33. extern void *dlopen __P ((__const char *__file, int __mode));
  34. /* Unmap and close a shared object opened by `dlopen'.
  35. The handle cannot be used again after calling `dlclose'. */
  36. extern int dlclose __P ((void *__handle));
  37. /* Find the run-time address in the shared object HANDLE refers to
  38. of the symbol called NAME. */
  39. extern void *dlsym __P ((void *__restrict __handle,
  40. __const char *__restrict __name));
  41. #ifdef __USE_GNU
  42. /* Find the run-time address in the shared object HANDLE refers to
  43. of the symbol called NAME with VERSION. */
  44. extern void *dlvsym __P ((void *__restrict __handle,
  45. __const char *__restrict __name,
  46. __const char *__restrict __version));
  47. #endif
  48. /* When any of the above functions fails, call this function
  49. to return a string describing the error. Each call resets
  50. the error string so that a following call returns null. */
  51. extern char *dlerror __P ((void));
  52. #ifdef __USE_GNU
  53. /* Fill in *INFO with the following information about ADDRESS.
  54. Returns 0 iff no shared object's segments contain that address. */
  55. typedef struct
  56. {
  57. __const char *dli_fname; /* File name of defining object. */
  58. void *dli_fbase; /* Load address of that object. */
  59. __const char *dli_sname; /* Name of nearest symbol. */
  60. void *dli_saddr; /* Exact value of nearest symbol. */
  61. } Dl_info;
  62. extern int dladdr __P ((const void *__address, Dl_info *__info));
  63. /* To support profiling of shared objects it is a good idea to call
  64. the function found using `dlsym' using the following macro since
  65. these calls do not use the PLT. But this would mean the dynamic
  66. loader has no chance to find out when the function is called. The
  67. macro applies the necessary magic so that profiling is possible.
  68. Rewrite
  69. foo = (*fctp) (arg1, arg2);
  70. into
  71. foo = DL_CALL_FCT (fctp, (arg1, arg2));
  72. */
  73. # define DL_CALL_FCT(fctp, args) \
  74. (_dl_mcount_wrapper_check (fctp), (*(fctp)) args)
  75. /* This function calls the profiling functions. */
  76. extern void _dl_mcount_wrapper_check __P ((void *__selfpc));
  77. #endif
  78. __END_DECLS
  79. #endif /* dlfcn.h */