dl-hash.h 3.0 KB

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