ld_hash.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef _HASH_H_
  2. #define _HASH_H_
  3. #include "elf.h"
  4. /* Header file that describes the internal data structures used by the
  5. * ELF dynamic linker. */
  6. struct link_map
  7. {
  8. /* These entries must be in this order to be compatible with the
  9. * interface used by gdb to obtain the list of symbols. */
  10. unsigned long l_addr; /* address at which object is mapped */
  11. char *l_name; /* full name of loaded object */
  12. Elf32_Dyn *l_ld; /* dynamic structure of object */
  13. struct link_map *l_next;
  14. struct link_map *l_prev;
  15. };
  16. /* The DT_DEBUG entry in the .dynamic section is given the address of
  17. * this structure. gdb can pick this up to obtain the correct list of
  18. * loaded modules. */
  19. struct r_debug
  20. {
  21. int r_version; /* debugging info version no */
  22. struct link_map *r_map; /* address of link_map */
  23. unsigned long r_brk; /* address of update routine */
  24. enum
  25. {
  26. RT_CONSISTENT,
  27. RT_ADD,
  28. RT_DELETE
  29. } r_state;
  30. unsigned long r_ldbase; /* base addr of ld.so */
  31. };
  32. #ifndef RTLD_NEXT
  33. #define RTLD_NEXT ((void*)-1)
  34. #endif
  35. struct dyn_elf{
  36. unsigned long flags;
  37. struct elf_resolve * dyn;
  38. struct dyn_elf * next_handle; /* Used by dlopen et al. */
  39. struct dyn_elf * next;
  40. };
  41. struct elf_resolve{
  42. /* These entries must be in this order to be compatible with the interface used
  43. by gdb to obtain the list of symbols. */
  44. char * loadaddr;
  45. char * libname;
  46. unsigned long dynamic_addr;
  47. struct elf_resolve * next;
  48. struct elf_resolve * prev;
  49. /* Nothing after this address is used by gdb. */
  50. enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
  51. struct dyn_elf * symbol_scope;
  52. unsigned short usage_count;
  53. unsigned short int init_flag;
  54. unsigned int nbucket;
  55. unsigned long * elf_buckets;
  56. /*
  57. * These are only used with ELF style shared libraries
  58. */
  59. unsigned long nchain;
  60. unsigned long * chains;
  61. unsigned long dynamic_info[24];
  62. unsigned long dynamic_size;
  63. unsigned long n_phent;
  64. Elf32_Phdr * ppnt;
  65. #ifdef __powerpc__
  66. /* this is used to store the address of relocation data words, so
  67. * we don't have to calculate it every time, which requires a divide */
  68. unsigned long data_words;
  69. #endif
  70. };
  71. #if 0
  72. /*
  73. * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
  74. * gdb can pick this up to obtain the correct list of loaded modules.
  75. */
  76. struct r_debug{
  77. int r_version;
  78. struct elf_resolve * link_map;
  79. unsigned long brk_fun;
  80. enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
  81. unsigned long ldbase;
  82. };
  83. #endif
  84. #define COPY_RELOCS_DONE 1
  85. #define RELOCS_DONE 2
  86. #define JMP_RELOCS_DONE 4
  87. #define INIT_FUNCS_CALLED 8
  88. extern struct dyn_elf * _dl_symbol_tables;
  89. extern struct elf_resolve * _dl_loaded_modules;
  90. extern struct dyn_elf * _dl_handles;
  91. extern struct elf_resolve * _dl_check_hashed_files(char * libname);
  92. extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
  93. char * loadaddr, unsigned long * dynamic_info,
  94. unsigned long dynamic_addr, unsigned long dynamic_size);
  95. extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
  96. unsigned long instr_addr, struct elf_resolve * f_tpnt,
  97. int copyrel);
  98. extern int _dl_linux_dynamic_link(void);
  99. extern char * _dl_library_path;
  100. extern char * _dl_not_lazy;
  101. extern unsigned long _dl_elf_hash(const char * name);
  102. static inline int _dl_symbol(char * name)
  103. {
  104. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  105. return 0;
  106. return 1;
  107. }
  108. #define DL_ERROR_NOFILE 1
  109. #define DL_ERROR_NOZERO 2
  110. #define DL_ERROR_NOTELF 3
  111. #define DL_ERROR_NOTMAGIC 4
  112. #define DL_ERROR_NOTDYN 5
  113. #define DL_ERROR_MMAP_FAILED 6
  114. #define DL_ERROR_NODYNAMIC 7
  115. #define DL_WRONG_RELOCS 8
  116. #define DL_BAD_HANDLE 9
  117. #define DL_NO_SYMBOL 10
  118. #endif /* _HASH_H_ */