dl-hash.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
  35. /*
  36. * These are only used with ELF style shared libraries
  37. */
  38. unsigned long nchain;
  39. unsigned long * chains;
  40. unsigned long dynamic_info[DYNAMIC_SIZE];
  41. unsigned long n_phent;
  42. Elf32_Phdr * ppnt;
  43. ElfW(Addr) relro_addr;
  44. size_t relro_size;
  45. #ifdef __powerpc__
  46. /* this is used to store the address of relocation data words, so
  47. * we don't have to calculate it every time, which requires a divide */
  48. unsigned long data_words;
  49. #endif
  50. };
  51. #define RELOCS_DONE 1
  52. #define JMP_RELOCS_DONE 2
  53. #define INIT_FUNCS_CALLED 4
  54. #define FINI_FUNCS_CALLED 8
  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. struct elf_resolve *mytpnt, 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_ */