dlfcn.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* System dependent definitions for run-time dynamic loading.
  17. Copyright (C) 1996-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _DLFCN_H
  31. # error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
  32. #endif
  33. /* The MODE argument to `dlopen' contains one of the following: */
  34. #define RTLD_LAZY 0x00001 /* Lazy function call binding. */
  35. #define RTLD_NOW 0x00002 /* Immediate function call binding. */
  36. #define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
  37. #define RTLD_NOLOAD 0x00004 /* Do not load the object. */
  38. #define RTLD_DEEPBIND 0x00008 /* Use deep binding. */
  39. /* If the following bit is set in the MODE argument to `dlopen',
  40. the symbols of the loaded object and its dependencies are made
  41. visible as if the object were linked directly into the program. */
  42. #define RTLD_GLOBAL 0x00100
  43. /* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.
  44. The implementation does this by default and so we can define the
  45. value to zero. */
  46. #define RTLD_LOCAL 0
  47. /* Do not delete object when closed. */
  48. #define RTLD_NODELETE 0x01000
  49. #ifdef __USE_GNU
  50. /* To support profiling of shared objects it is a good idea to call
  51. the function found using `dlsym' using the following macro since
  52. these calls do not use the PLT. But this would mean the dynamic
  53. loader has no chance to find out when the function is called. The
  54. macro applies the necessary magic so that profiling is possible.
  55. Rewrite
  56. foo = (*fctp) (arg1, arg2);
  57. into
  58. foo = DL_CALL_FCT (fctp, (arg1, arg2));
  59. */
  60. # define DL_CALL_FCT(fctp, args) \
  61. (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)
  62. __BEGIN_DECLS
  63. /* This function calls the profiling functions. */
  64. extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW;
  65. __END_DECLS
  66. #endif