ldso.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  4. *
  5. * GNU Lesser General Public License version 2.1 or later.
  6. */
  7. #ifndef _LDSO_H_
  8. #define _LDSO_H_
  9. #include <features.h>
  10. /* Prepare for the case that `__builtin_expect' is not available. */
  11. #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
  12. #define __builtin_expect(x, expected_value) (x)
  13. #endif
  14. #ifndef likely
  15. # define likely(x) __builtin_expect((!!(x)),1)
  16. #endif
  17. #ifndef unlikely
  18. # define unlikely(x) __builtin_expect((!!(x)),0)
  19. #endif
  20. #ifndef __LINUX_COMPILER_H
  21. #define __LINUX_COMPILER_H
  22. #endif
  23. /* Pull in compiler and arch stuff */
  24. #include <stdlib.h>
  25. #include <stdarg.h>
  26. #define _FCNTL_H
  27. #include <bits/fcntl.h>
  28. #include <bits/wordsize.h>
  29. /* Pull in the arch specific type information */
  30. #include <sys/types.h>
  31. /* Pull in the arch specific page size */
  32. #include <bits/uClibc_page.h>
  33. /* Pull in the ldso syscalls and string functions */
  34. #ifndef __ARCH_HAS_NO_SHARED__
  35. #include <dl-syscall.h>
  36. #include <dl-string.h>
  37. #include <dlfcn.h>
  38. /* Now the ldso specific headers */
  39. #include <dl-elf.h>
  40. #ifdef __UCLIBC_HAS_TLS__
  41. /* Defines USE_TLS */
  42. #include <tls.h>
  43. #endif
  44. #include <dl-hash.h>
  45. /* common align masks, if not specified by sysdep headers */
  46. #ifndef ADDR_ALIGN
  47. #define ADDR_ALIGN (_dl_pagesize - 1)
  48. #endif
  49. #ifndef PAGE_ALIGN
  50. #define PAGE_ALIGN (~ADDR_ALIGN)
  51. #endif
  52. #ifndef OFFS_ALIGN
  53. #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
  54. #endif
  55. /* For INIT/FINI dependency sorting. */
  56. struct init_fini_list {
  57. struct init_fini_list *next;
  58. struct elf_resolve *tpnt;
  59. };
  60. /* Global variables used within the shared library loader */
  61. extern char *_dl_library_path; /* Where we look for libraries */
  62. extern char *_dl_preload; /* Things to be loaded before the libs */
  63. extern char *_dl_ldsopath; /* Where the shared lib loader was found */
  64. extern const char *_dl_progname; /* The name of the executable being run */
  65. extern size_t _dl_pagesize; /* Store the page size for use later */
  66. #if defined(USE_TLS) && USE_TLS
  67. extern void _dl_add_to_slotinfo (struct link_map *l);
  68. extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
  69. #endif
  70. #ifdef USE_TLS
  71. void _dl_add_to_slotinfo (struct link_map *l);
  72. void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
  73. #endif
  74. #ifdef __SUPPORT_LD_DEBUG__
  75. extern char *_dl_debug;
  76. extern char *_dl_debug_symbols;
  77. extern char *_dl_debug_move;
  78. extern char *_dl_debug_reloc;
  79. extern char *_dl_debug_detail;
  80. extern char *_dl_debug_nofixups;
  81. extern char *_dl_debug_bindings;
  82. extern int _dl_debug_file;
  83. # define __dl_debug_dprint(fmt, args...) \
  84. _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
  85. # define _dl_if_debug_dprint(fmt, args...) \
  86. do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
  87. #else
  88. # define __dl_debug_dprint(fmt, args...) do {} while (0)
  89. # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
  90. # define _dl_debug_file 2
  91. #endif /* __SUPPORT_LD_DEBUG__ */
  92. #ifdef IS_IN_rtld
  93. # ifdef __SUPPORT_LD_DEBUG__
  94. # define _dl_assert(expr) \
  95. do { \
  96. if (!(expr)) { \
  97. __dl_debug_dprint("assert(%s)\n", #expr); \
  98. _dl_exit(45); \
  99. } \
  100. } while (0)
  101. # else
  102. # define _dl_assert(expr) ((void)0)
  103. # endif
  104. #else
  105. # include <assert.h>
  106. # define _dl_assert(expr) assert(expr)
  107. #endif
  108. #ifdef __SUPPORT_LD_DEBUG_EARLY__
  109. # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
  110. #else
  111. # define _dl_debug_early(fmt, args...) do {} while (0)
  112. #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
  113. #ifndef NULL
  114. #define NULL ((void *) 0)
  115. #endif
  116. extern void *_dl_malloc(size_t size);
  117. extern void *_dl_calloc(size_t __nmemb, size_t __size);
  118. extern void *_dl_realloc(void *__ptr, size_t __size);
  119. extern void _dl_free(void *);
  120. extern char *_dl_getenv(const char *symbol, char **envp);
  121. extern void _dl_unsetenv(const char *symbol, char **envp);
  122. extern char *_dl_strdup(const char *string);
  123. extern void _dl_dprintf(int, const char *, ...);
  124. #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
  125. # define DL_GET_READY_TO_RUN_EXTRA_PARMS
  126. #endif
  127. #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
  128. # define DL_GET_READY_TO_RUN_EXTRA_ARGS
  129. #endif
  130. extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
  131. ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
  132. DL_GET_READY_TO_RUN_EXTRA_PARMS);
  133. #ifdef HAVE_DL_INLINES_H
  134. #include <dl-inlines.h>
  135. #endif
  136. #else /* __ARCH_HAS_NO_SHARED__ */
  137. #include <dl-defs.h>
  138. #endif
  139. #endif /* _LDSO_H_ */