ld_hash.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef _LD_HASH_H_
  2. #define _LD_HASH_H_
  3. #ifndef RTLD_NEXT
  4. #define RTLD_NEXT ((void*)-1)
  5. #endif
  6. struct dyn_elf{
  7. unsigned long flags;
  8. struct elf_resolve * dyn;
  9. struct dyn_elf * next_handle; /* Used by dlopen et al. */
  10. struct dyn_elf * next;
  11. struct dyn_elf * prev;
  12. };
  13. struct elf_resolve{
  14. /* These entries must be in this order to be compatible with the interface used
  15. by gdb to obtain the list of symbols. */
  16. char * loadaddr;
  17. char * libname;
  18. unsigned long dynamic_addr;
  19. struct elf_resolve * next;
  20. struct elf_resolve * prev;
  21. /* Nothing after this address is used by gdb. */
  22. enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
  23. struct dyn_elf * symbol_scope;
  24. unsigned short usage_count;
  25. unsigned short int init_flag;
  26. unsigned int nbucket;
  27. unsigned long * elf_buckets;
  28. /*
  29. * These are only used with ELF style shared libraries
  30. */
  31. unsigned long nchain;
  32. unsigned long * chains;
  33. unsigned long dynamic_info[24];
  34. unsigned long dynamic_size;
  35. unsigned long n_phent;
  36. Elf32_Phdr * ppnt;
  37. #if defined(__mips__)
  38. /* Needed for MIPS relocation */
  39. unsigned long mips_gotsym;
  40. unsigned long mips_local_gotno;
  41. unsigned long mips_symtabno;
  42. #endif
  43. #ifdef __powerpc__
  44. /* this is used to store the address of relocation data words, so
  45. * we don't have to calculate it every time, which requires a divide */
  46. unsigned long data_words;
  47. #endif
  48. };
  49. #if 0
  50. /*
  51. * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
  52. * gdb can pick this up to obtain the correct list of loaded modules.
  53. */
  54. struct r_debug{
  55. int r_version;
  56. struct elf_resolve * link_map;
  57. unsigned long brk_fun;
  58. enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
  59. unsigned long ldbase;
  60. };
  61. #endif
  62. #define COPY_RELOCS_DONE 1
  63. #define RELOCS_DONE 2
  64. #define JMP_RELOCS_DONE 4
  65. #define INIT_FUNCS_CALLED 8
  66. extern struct dyn_elf * _dl_symbol_tables;
  67. extern struct elf_resolve * _dl_loaded_modules;
  68. extern struct dyn_elf * _dl_handles;
  69. extern struct elf_resolve * _dl_check_hashed_files(const char * libname);
  70. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  71. char * loadaddr, unsigned long * dynamic_info,
  72. unsigned long dynamic_addr, unsigned long dynamic_size);
  73. enum caller_type{symbolrel=0,copyrel=1,resolver=2};
  74. extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1,
  75. struct elf_resolve * f_tpnt, enum caller_type);
  76. extern int _dl_linux_dynamic_link(void);
  77. extern char * _dl_library_path;
  78. extern char * _dl_not_lazy;
  79. extern unsigned long _dl_elf_hash(const char * name);
  80. static inline int _dl_symbol(char * name)
  81. {
  82. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  83. return 0;
  84. return 1;
  85. }
  86. #define LD_ERROR_NOFILE 1
  87. #define LD_ERROR_NOZERO 2
  88. #define LD_ERROR_NOTELF 3
  89. #define LD_ERROR_NOTMAGIC 4
  90. #define LD_ERROR_NOTDYN 5
  91. #define LD_ERROR_MMAP_FAILED 6
  92. #define LD_ERROR_NODYNAMIC 7
  93. #define LD_WRONG_RELOCS 8
  94. #define LD_BAD_HANDLE 9
  95. #define LD_NO_SYMBOL 10
  96. #endif /* _LD_HASH_H_ */