dl-hash.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. Elf_Symndx nbucket;
  32. Elf_Symndx *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. Elf_Symndx nchain;
  39. Elf_Symndx *chains;
  40. unsigned long dynamic_info[DYNAMIC_SIZE];
  41. unsigned long n_phent;
  42. ElfW(Phdr) * ppnt;
  43. ElfW(Addr) relro_addr;
  44. size_t relro_size;
  45. dev_t st_dev; /* device */
  46. ino_t st_ino; /* inode */
  47. #ifdef __powerpc__
  48. /* this is used to store the address of relocation data words, so
  49. * we don't have to calculate it every time, which requires a divide */
  50. unsigned long data_words;
  51. #endif
  52. };
  53. #define RELOCS_DONE 0x000001
  54. #define JMP_RELOCS_DONE 0x000002
  55. #define INIT_FUNCS_CALLED 0x000004
  56. #define FINI_FUNCS_CALLED 0x000008
  57. #define DL_OPENED 0x000010
  58. extern struct dyn_elf * _dl_symbol_tables;
  59. extern struct elf_resolve * _dl_loaded_modules;
  60. extern struct dyn_elf * _dl_handles;
  61. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  62. char * loadaddr, unsigned long * dynamic_info,
  63. unsigned long dynamic_addr, unsigned long dynamic_size);
  64. extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1,
  65. struct elf_resolve *mytpnt, int type_class);
  66. extern int _dl_linux_dynamic_link(void);
  67. extern char * _dl_library_path;
  68. extern char * _dl_not_lazy;
  69. static inline int _dl_symbol(char * name)
  70. {
  71. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  72. return 0;
  73. return 1;
  74. }
  75. #define LD_ERROR_NOFILE 1
  76. #define LD_ERROR_NOZERO 2
  77. #define LD_ERROR_NOTELF 3
  78. #define LD_ERROR_NOTMAGIC 4
  79. #define LD_ERROR_NOTDYN 5
  80. #define LD_ERROR_MMAP_FAILED 6
  81. #define LD_ERROR_NODYNAMIC 7
  82. #define LD_WRONG_RELOCS 8
  83. #define LD_BAD_HANDLE 9
  84. #define LD_NO_SYMBOL 10
  85. #endif /* _LD_HASH_H_ */