ldsodefs.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef _LDSODEFS_H
  2. #define _LDSODEFS_H 1
  3. #include <bits/kernel-features.h>
  4. #include <features.h>
  5. #include <tls.h>
  6. #ifdef __mips__
  7. /* The MIPS ABI specifies that the dynamic section has to be read-only. */
  8. #define DL_RO_DYN_SECTION 1
  9. /* TODO: Import in 64-bit relocations from glibc. */
  10. #endif
  11. #ifndef SHARED
  12. # define EXTERN extern
  13. #else
  14. # ifdef IS_IN_rtld
  15. # define EXTERN
  16. # else
  17. # define EXTERN extern
  18. # endif
  19. #endif
  20. /* Non-shared code has no support for multiple namespaces. */
  21. #ifdef SHARED
  22. # define DL_NNS 16
  23. #else
  24. # define DL_NNS 1
  25. #endif
  26. #define GL(x) _##x
  27. #define GLRO(x) _##x
  28. /* Variable pointing to the end of the stack (or close to it). This value
  29. must be constant over the runtime of the application. Some programs
  30. might use the variable which results in copy relocations on some
  31. platforms. But this does not matter, ld.so can always use the local
  32. copy. */
  33. extern void *__libc_stack_end;
  34. /* Determine next available module ID. */
  35. extern size_t _dl_next_tls_modid (void) internal_function attribute_hidden;
  36. /* Calculate offset of the TLS blocks in the static TLS block. */
  37. extern void _dl_determine_tlsoffset (void) internal_function attribute_hidden;
  38. /* Set up the data structures for TLS, when they were not set up at startup.
  39. Returns nonzero on malloc failure.
  40. This is called from _dl_map_object_from_fd or by libpthread. */
  41. extern int _dl_tls_setup (void) internal_function;
  42. rtld_hidden_proto (_dl_tls_setup)
  43. /* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */
  44. extern void *_dl_allocate_tls (void *mem) internal_function;
  45. /* Get size and alignment requirements of the static TLS block. */
  46. extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp)
  47. internal_function;
  48. extern void _dl_allocate_static_tls (struct link_map *map)
  49. internal_function attribute_hidden;
  50. /* Taken from glibc/elf/dl-reloc.c */
  51. #define CHECK_STATIC_TLS(sym_map) \
  52. do { \
  53. if (unlikely((sym_map)->l_tls_offset == NO_TLS_OFFSET)) \
  54. _dl_allocate_static_tls (sym_map); \
  55. } while (0)
  56. /* These are internal entry points to the two halves of _dl_allocate_tls,
  57. only used within rtld.c itself at startup time. */
  58. extern void *_dl_allocate_tls_storage (void)
  59. internal_function attribute_hidden;
  60. extern void *_dl_allocate_tls_init (void *) internal_function;
  61. /* Deallocate memory allocated with _dl_allocate_tls. */
  62. extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function;
  63. extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden;
  64. /* Highest dtv index currently needed. */
  65. EXTERN size_t _dl_tls_max_dtv_idx;
  66. /* Flag signalling whether there are gaps in the module ID allocation. */
  67. EXTERN bool _dl_tls_dtv_gaps;
  68. /* Information about the dtv slots. */
  69. EXTERN struct dtv_slotinfo_list
  70. {
  71. size_t len;
  72. struct dtv_slotinfo_list *next;
  73. struct dtv_slotinfo
  74. {
  75. size_t gen;
  76. bool is_static;
  77. struct link_map *map;
  78. } slotinfo[0];
  79. } *_dl_tls_dtv_slotinfo_list;
  80. /* Number of modules in the static TLS block. */
  81. EXTERN size_t _dl_tls_static_nelem;
  82. /* Size of the static TLS block. */
  83. EXTERN size_t _dl_tls_static_size;
  84. /* Size actually allocated in the static TLS block. */
  85. EXTERN size_t _dl_tls_static_used;
  86. /* Alignment requirement of the static TLS block. */
  87. EXTERN size_t _dl_tls_static_align;
  88. /* Function pointer for catching TLS errors. */
  89. EXTERN void **(*_dl_error_catch_tsd) (void) __attribute__ ((const));
  90. /* Number of additional entries in the slotinfo array of each slotinfo
  91. list element. A large number makes it almost certain take we never
  92. have to iterate beyond the first element in the slotinfo list. */
  93. # define TLS_SLOTINFO_SURPLUS (62)
  94. /* Number of additional slots in the dtv allocated. */
  95. # define DTV_SURPLUS (14)
  96. /* Initial dtv of the main thread, not allocated with normal malloc. */
  97. EXTERN void *_dl_initial_dtv;
  98. /* Generation counter for the dtv. */
  99. EXTERN size_t _dl_tls_generation;
  100. EXTERN void (*_dl_init_static_tls) (struct link_map *);
  101. /* We have the auxiliary vector. */
  102. #define HAVE_AUX_VECTOR
  103. /* We can assume that the kernel always provides the AT_UID, AT_EUID,
  104. AT_GID, and AT_EGID values in the auxiliary vector from 2.4.0 or so on. */
  105. #if __ASSUME_AT_XID
  106. # define HAVE_AUX_XID
  107. #endif
  108. /* We can assume that the kernel always provides the AT_SECURE value
  109. in the auxiliary vector from 2.5.74 or so on. */
  110. #if __ASSUME_AT_SECURE
  111. # define HAVE_AUX_SECURE
  112. #endif
  113. /* Starting with one of the 2.4.0 pre-releases the Linux kernel passes
  114. up the page size information. */
  115. #if __ASSUME_AT_PAGESIZE
  116. # define HAVE_AUX_PAGESIZE
  117. #endif
  118. #endif