ld_hash.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef _HASH_H_
  2. #define _HASH_H_
  3. #include "linuxelf.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. #if defined(__mips__)
  66. /* Needed for MIPS relocation */
  67. unsigned long mips_gotsym;
  68. unsigned long mips_local_gotno;
  69. unsigned long mips_symtabno;
  70. #endif
  71. #ifdef __powerpc__
  72. /* this is used to store the address of relocation data words, so
  73. * we don't have to calculate it every time, which requires a divide */
  74. unsigned long data_words;
  75. #endif
  76. };
  77. #if 0
  78. /*
  79. * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
  80. * gdb can pick this up to obtain the correct list of loaded modules.
  81. */
  82. struct r_debug{
  83. int r_version;
  84. struct elf_resolve * link_map;
  85. unsigned long brk_fun;
  86. enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
  87. unsigned long ldbase;
  88. };
  89. #endif
  90. #define COPY_RELOCS_DONE 1
  91. #define RELOCS_DONE 2
  92. #define JMP_RELOCS_DONE 4
  93. #define INIT_FUNCS_CALLED 8
  94. extern struct dyn_elf * _dl_symbol_tables;
  95. extern struct elf_resolve * _dl_loaded_modules;
  96. extern struct dyn_elf * _dl_handles;
  97. extern struct elf_resolve * _dl_check_hashed_files(char * libname);
  98. extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
  99. char * loadaddr, unsigned long * dynamic_info,
  100. unsigned long dynamic_addr, unsigned long dynamic_size);
  101. extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
  102. struct elf_resolve * f_tpnt, int copyrel);
  103. extern int _dl_linux_dynamic_link(void);
  104. extern char * _dl_library_path;
  105. extern char * _dl_not_lazy;
  106. extern unsigned long _dl_elf_hash(const char * name);
  107. static inline int _dl_symbol(char * name)
  108. {
  109. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  110. return 0;
  111. return 1;
  112. }
  113. #define DL_ERROR_NOFILE 1
  114. #define DL_ERROR_NOZERO 2
  115. #define DL_ERROR_NOTELF 3
  116. #define DL_ERROR_NOTMAGIC 4
  117. #define DL_ERROR_NOTDYN 5
  118. #define DL_ERROR_MMAP_FAILED 6
  119. #define DL_ERROR_NODYNAMIC 7
  120. #define DL_WRONG_RELOCS 8
  121. #define DL_BAD_HANDLE 9
  122. #define DL_NO_SYMBOL 10
  123. #endif /* _HASH_H_ */