dl-hash.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. 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 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. #define COPY_RELOCS_DONE 1
  50. #define RELOCS_DONE 2
  51. #define JMP_RELOCS_DONE 4
  52. #define INIT_FUNCS_CALLED 8
  53. extern struct dyn_elf * _dl_symbol_tables;
  54. extern struct elf_resolve * _dl_loaded_modules;
  55. extern struct dyn_elf * _dl_handles;
  56. extern struct elf_resolve * _dl_check_hashed_files(const char * libname);
  57. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  58. char * loadaddr, unsigned long * dynamic_info,
  59. unsigned long dynamic_addr, unsigned long dynamic_size);
  60. enum caller_type{symbolrel=0,copyrel=1,resolver=2};
  61. extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1,
  62. struct elf_resolve * f_tpnt, enum caller_type);
  63. extern int _dl_linux_dynamic_link(void);
  64. extern char * _dl_library_path;
  65. extern char * _dl_not_lazy;
  66. extern unsigned long _dl_elf_hash(const char * name);
  67. static inline int _dl_symbol(char * name)
  68. {
  69. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  70. return 0;
  71. return 1;
  72. }
  73. #define LD_ERROR_NOFILE 1
  74. #define LD_ERROR_NOZERO 2
  75. #define LD_ERROR_NOTELF 3
  76. #define LD_ERROR_NOTMAGIC 4
  77. #define LD_ERROR_NOTDYN 5
  78. #define LD_ERROR_MMAP_FAILED 6
  79. #define LD_ERROR_NODYNAMIC 7
  80. #define LD_WRONG_RELOCS 8
  81. #define LD_BAD_HANDLE 9
  82. #define LD_NO_SYMBOL 10
  83. #endif /* _LD_HASH_H_ */