ldso.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #include <bits/wordsize.h>
  27. /* Pull in the arch specific type information */
  28. #include <sys/types.h>
  29. /* Pull in the arch specific page size */
  30. #include <bits/uClibc_page.h>
  31. /* Pull in the ldso syscalls and string functions */
  32. #include <dl-syscall.h>
  33. #include <dl-string.h>
  34. /* Now the ldso specific headers */
  35. #include <dl-elf.h>
  36. #include <dl-hash.h>
  37. /* common align masks, if not specified by sysdep headers */
  38. #ifndef ADDR_ALIGN
  39. #define ADDR_ALIGN (_dl_pagesize - 1)
  40. #endif
  41. #ifndef PAGE_ALIGN
  42. #define PAGE_ALIGN (~ADDR_ALIGN)
  43. #endif
  44. #ifndef OFFS_ALIGN
  45. #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
  46. #endif
  47. /* For INIT/FINI dependency sorting. */
  48. struct init_fini_list {
  49. struct init_fini_list *next;
  50. struct elf_resolve *tpnt;
  51. };
  52. /* Global variables used within the shared library loader */
  53. extern char *_dl_library_path; /* Where we look for libraries */
  54. extern char *_dl_preload; /* Things to be loaded before the libs */
  55. extern char *_dl_ldsopath; /* Where the shared lib loader was found */
  56. extern const char *_dl_progname; /* The name of the executable being run */
  57. extern size_t _dl_pagesize; /* Store the page size for use later */
  58. #ifdef __SUPPORT_LD_DEBUG__
  59. extern char *_dl_debug;
  60. extern char *_dl_debug_symbols;
  61. extern char *_dl_debug_move;
  62. extern char *_dl_debug_reloc;
  63. extern char *_dl_debug_detail;
  64. extern char *_dl_debug_nofixups;
  65. extern char *_dl_debug_bindings;
  66. extern int _dl_debug_file;
  67. # define __dl_debug_dprint(fmt, args...) \
  68. _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
  69. # define _dl_if_debug_dprint(fmt, args...) \
  70. do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
  71. #else
  72. # define __dl_debug_dprint(fmt, args...) do {} while (0)
  73. # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
  74. # define _dl_debug_file 2
  75. #endif /* __SUPPORT_LD_DEBUG__ */
  76. #ifdef IS_IN_rtld
  77. # ifdef __SUPPORT_LD_DEBUG__
  78. # define _dl_assert(expr) \
  79. do { \
  80. if (!(expr)) { \
  81. __dl_debug_dprint("assert(%s)\n", #expr); \
  82. _dl_exit(45); \
  83. } \
  84. } while (0)
  85. # else
  86. # define _dl_assert(expr) ((void)0)
  87. # endif
  88. #else
  89. # include <assert.h>
  90. # define _dl_assert(expr) assert(expr)
  91. #endif
  92. #ifdef __SUPPORT_LD_DEBUG_EARLY__
  93. # define _dl_debug_early(fmt, args...) __dl_debug_dprint(fmt, ## args)
  94. #else
  95. # define _dl_debug_early(fmt, args...) do {} while (0)
  96. #endif /* __SUPPORT_LD_DEBUG_EARLY__ */
  97. #ifndef NULL
  98. #define NULL ((void *) 0)
  99. #endif
  100. extern void *_dl_malloc(size_t size);
  101. extern void _dl_free(void *);
  102. extern char *_dl_getenv(const char *symbol, char **envp);
  103. extern void _dl_unsetenv(const char *symbol, char **envp);
  104. extern char *_dl_strdup(const char *string);
  105. extern void _dl_dprintf(int, const char *, ...);
  106. #ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
  107. # define DL_GET_READY_TO_RUN_EXTRA_PARMS
  108. #endif
  109. #ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS
  110. # define DL_GET_READY_TO_RUN_EXTRA_ARGS
  111. #endif
  112. extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
  113. ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
  114. DL_GET_READY_TO_RUN_EXTRA_PARMS);
  115. #ifdef HAVE_DL_INLINES_H
  116. #include <dl-inlines.h>
  117. #endif
  118. #endif /* _LDSO_H_ */