dl-hash.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. struct elf_resolve * dyn;
  8. struct dyn_elf * next_handle; /* Used by dlopen et al. */
  9. struct init_fini_list *init_fini;
  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. ElfW(Addr) loadaddr; /* Base address shared object is loaded at. */
  17. char *libname; /* Absolute file name object was found in. */
  18. ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
  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 long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
  27. unsigned int nbucket;
  28. unsigned long * elf_buckets;
  29. /*
  30. * These are only used with ELF style shared libraries
  31. */
  32. unsigned long nchain;
  33. unsigned long * chains;
  34. unsigned long dynamic_info[24];
  35. unsigned long dynamic_size;
  36. unsigned long n_phent;
  37. Elf32_Phdr * ppnt;
  38. #if defined(__mips__)
  39. /* Needed for MIPS relocation */
  40. unsigned long mips_gotsym;
  41. unsigned long mips_local_gotno;
  42. unsigned long mips_symtabno;
  43. #endif
  44. #ifdef __powerpc__
  45. /* this is used to store the address of relocation data words, so
  46. * we don't have to calculate it every time, which requires a divide */
  47. unsigned long data_words;
  48. #endif
  49. };
  50. #define COPY_RELOCS_DONE 1
  51. #define RELOCS_DONE 2
  52. #define JMP_RELOCS_DONE 4
  53. #define INIT_FUNCS_CALLED 8
  54. #define FINI_FUNCS_CALLED 16
  55. extern struct dyn_elf * _dl_symbol_tables;
  56. extern struct elf_resolve * _dl_loaded_modules;
  57. extern struct dyn_elf * _dl_handles;
  58. extern struct elf_resolve * _dl_check_hashed_files(const char * libname);
  59. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  60. char * loadaddr, unsigned long * dynamic_info,
  61. unsigned long dynamic_addr, unsigned long dynamic_size);
  62. extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1,
  63. int type_class);
  64. extern int _dl_linux_dynamic_link(void);
  65. extern char * _dl_library_path;
  66. extern char * _dl_not_lazy;
  67. extern unsigned long _dl_elf_hash(const unsigned char *name);
  68. static inline int _dl_symbol(char * name)
  69. {
  70. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  71. return 0;
  72. return 1;
  73. }
  74. #define LD_ERROR_NOFILE 1
  75. #define LD_ERROR_NOZERO 2
  76. #define LD_ERROR_NOTELF 3
  77. #define LD_ERROR_NOTMAGIC 4
  78. #define LD_ERROR_NOTDYN 5
  79. #define LD_ERROR_MMAP_FAILED 6
  80. #define LD_ERROR_NODYNAMIC 7
  81. #define LD_WRONG_RELOCS 8
  82. #define LD_BAD_HANDLE 9
  83. #define LD_NO_SYMBOL 10
  84. #endif /* _LD_HASH_H_ */