hash.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #ifdef __mc68000__
  65. /* On m68k 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 (__s)); \
  71. }
  72. #else
  73. #define SEND_STDERR(X) _dl_write(2, X, _dl_strlen(X));
  74. #endif
  75. extern int _dl_fdprintf(int, const char *, ...);
  76. extern char * _dl_library_path;
  77. extern char * _dl_not_lazy;
  78. extern char * _dl_strdup(const char *);
  79. extern inline int _dl_symbol(char * name);
  80. unsigned long _dl_elf_hash(const char * name);
  81. extern inline int _dl_symbol(char * name)
  82. {
  83. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  84. return 0;
  85. return 1;
  86. }
  87. #define DL_ERROR_NOFILE 1
  88. #define DL_ERROR_NOZERO 2
  89. #define DL_ERROR_NOTELF 3
  90. #define DL_ERROR_NOTMAGIC 4
  91. #define DL_ERROR_NOTDYN 5
  92. #define DL_ERROR_MMAP_FAILED 6
  93. #define DL_ERROR_NODYNAMIC 7
  94. #define DL_WRONG_RELOCS 8
  95. #define DL_BAD_HANDLE 9
  96. #define DL_NO_SYMBOL 10