ld_hash.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. Elf32_Addr 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. struct dyn_elf * prev;
  41. };
  42. struct elf_resolve{
  43. /* These entries must be in this order to be compatible with the interface used
  44. by gdb to obtain the list of symbols. */
  45. char * loadaddr;
  46. char * libname;
  47. unsigned long dynamic_addr;
  48. struct elf_resolve * next;
  49. struct elf_resolve * prev;
  50. /* Nothing after this address is used by gdb. */
  51. enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
  52. struct dyn_elf * symbol_scope;
  53. unsigned short usage_count;
  54. unsigned short int init_flag;
  55. unsigned int nbucket;
  56. unsigned long * elf_buckets;
  57. /*
  58. * These are only used with ELF style shared libraries
  59. */
  60. unsigned long nchain;
  61. unsigned long * chains;
  62. unsigned long dynamic_info[24];
  63. unsigned long dynamic_size;
  64. unsigned long n_phent;
  65. Elf32_Phdr * ppnt;
  66. #if defined(__mips__)
  67. /* Needed for MIPS relocation */
  68. unsigned long mips_gotsym;
  69. unsigned long mips_local_gotno;
  70. unsigned long mips_symtabno;
  71. #endif
  72. #ifdef __powerpc__
  73. /* this is used to store the address of relocation data words, so
  74. * we don't have to calculate it every time, which requires a divide */
  75. unsigned long data_words;
  76. #endif
  77. };
  78. #if 0
  79. /*
  80. * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
  81. * gdb can pick this up to obtain the correct list of loaded modules.
  82. */
  83. struct r_debug{
  84. int r_version;
  85. struct elf_resolve * link_map;
  86. unsigned long brk_fun;
  87. enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
  88. unsigned long ldbase;
  89. };
  90. #endif
  91. #define COPY_RELOCS_DONE 1
  92. #define RELOCS_DONE 2
  93. #define JMP_RELOCS_DONE 4
  94. #define INIT_FUNCS_CALLED 8
  95. extern struct dyn_elf * _dl_symbol_tables;
  96. extern struct elf_resolve * _dl_loaded_modules;
  97. extern struct dyn_elf * _dl_handles;
  98. extern struct elf_resolve * _dl_check_hashed_files(const char * libname);
  99. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  100. char * loadaddr, unsigned long * dynamic_info,
  101. unsigned long dynamic_addr, unsigned long dynamic_size);
  102. enum caller_type{symbolrel=0,copyrel=1,resolver=2};
  103. extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1,
  104. struct elf_resolve * f_tpnt, enum caller_type);
  105. extern int _dl_linux_dynamic_link(void);
  106. extern char * _dl_library_path;
  107. extern char * _dl_not_lazy;
  108. extern unsigned long _dl_elf_hash(const char * name);
  109. static inline int _dl_symbol(char * name)
  110. {
  111. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  112. return 0;
  113. return 1;
  114. }
  115. #define LD_ERROR_NOFILE 1
  116. #define LD_ERROR_NOZERO 2
  117. #define LD_ERROR_NOTELF 3
  118. #define LD_ERROR_NOTMAGIC 4
  119. #define LD_ERROR_NOTDYN 5
  120. #define LD_ERROR_MMAP_FAILED 6
  121. #define LD_ERROR_NODYNAMIC 7
  122. #define LD_WRONG_RELOCS 8
  123. #define LD_BAD_HANDLE 9
  124. #define LD_NO_SYMBOL 10
  125. #endif /* _HASH_H_ */