hash.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include "link.h"
  2. #ifndef RTLD_NEXT
  3. #define RTLD_NEXT ((void*)-1)
  4. #endif
  5. struct dyn_elf{
  6. unsigned long flags;
  7. struct elf_resolve * dyn;
  8. struct dyn_elf * next_handle; /* Used by dlopen et al. */
  9. struct dyn_elf * next;
  10. };
  11. struct elf_resolve{
  12. /* These entries must be in this order to be compatible with the interface used
  13. by gdb to obtain the list of symbols. */
  14. char * loadaddr;
  15. char * libname;
  16. unsigned long dynamic_addr;
  17. struct elf_resolve * next;
  18. struct elf_resolve * prev;
  19. /* Nothing after this address is used by gdb. */
  20. enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
  21. struct dyn_elf * symbol_scope;
  22. unsigned short usage_count;
  23. unsigned short int init_flag;
  24. unsigned int nbucket;
  25. unsigned long * elf_buckets;
  26. /*
  27. * These are only used with ELF style shared libraries
  28. */
  29. unsigned long nchain;
  30. unsigned long * chains;
  31. unsigned long dynamic_info[24];
  32. unsigned long dynamic_size;
  33. unsigned long n_phent;
  34. Elf32_Phdr * ppnt;
  35. };
  36. #if 0
  37. /*
  38. * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
  39. * gdb can pick this up to obtain the correct list of loaded modules.
  40. */
  41. struct r_debug{
  42. int r_version;
  43. struct elf_resolve * link_map;
  44. unsigned long brk_fun;
  45. enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
  46. unsigned long ldbase;
  47. };
  48. #endif
  49. #define COPY_RELOCS_DONE 1
  50. #define RELOCS_DONE 2
  51. #define JMP_RELOCS_DONE 4
  52. #define INIT_FUNCS_CALLED 8
  53. extern struct dyn_elf * _dl_symbol_tables;
  54. extern struct elf_resolve * _dl_loaded_modules;
  55. extern struct dyn_elf * _dl_handles;
  56. extern struct elf_resolve * _dl_check_hashed_files(char * libname);
  57. extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
  58. char * loadaddr, unsigned long * dynamic_info,
  59. unsigned long dynamic_addr, unsigned long dynamic_size);
  60. extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
  61. unsigned long instr_addr, struct elf_resolve * f_tpnt,
  62. int copyrel);
  63. extern int _dl_linux_dynamic_link(void);
  64. #if defined mc68000 || defined __arm__
  65. /* On some arches constant strings are referenced through the GOT. */
  66. /* XXX Requires load_addr to be defined. */
  67. #define SEND_STDERR(X) \
  68. { const char *__s = (X); \
  69. if (__s < (const char *) load_addr) __s += load_addr; \
  70. _dl_write (2, __s, _dl_strlen_inline (__s)); \
  71. }
  72. #else
  73. #define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
  74. #endif
  75. #define SEND_ADDRESS_STDERR(X, add_a_newline) { \
  76. char tmp[13], *tmp1; \
  77. _dl_memset_inline(tmp, 0, sizeof(tmp)); \
  78. tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
  79. _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
  80. if (add_a_newline) { \
  81. tmp[0]='\n'; \
  82. _dl_write(2, tmp, 1); \
  83. } \
  84. };
  85. #define SEND_NUMBER_STDERR(X, add_a_newline) { \
  86. char tmp[13], *tmp1; \
  87. _dl_memset_inline(tmp, 0, sizeof(tmp)); \
  88. tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
  89. _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
  90. if (add_a_newline) { \
  91. tmp[0]='\n'; \
  92. _dl_write(2, tmp, 1); \
  93. } \
  94. };
  95. extern int _dl_fdprintf(int, const char *, ...);
  96. extern char * _dl_library_path;
  97. extern char * _dl_not_lazy;
  98. extern char * _dl_strdup(const char *);
  99. extern unsigned long _dl_elf_hash(const char * name);
  100. static inline int _dl_symbol(char * name)
  101. {
  102. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  103. return 0;
  104. return 1;
  105. }
  106. #define DL_ERROR_NOFILE 1
  107. #define DL_ERROR_NOZERO 2
  108. #define DL_ERROR_NOTELF 3
  109. #define DL_ERROR_NOTMAGIC 4
  110. #define DL_ERROR_NOTDYN 5
  111. #define DL_ERROR_MMAP_FAILED 6
  112. #define DL_ERROR_NODYNAMIC 7
  113. #define DL_WRONG_RELOCS 8
  114. #define DL_BAD_HANDLE 9
  115. #define DL_NO_SYMBOL 10