ld_hash.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "link.h"
  2. #ifndef RTLD_NEXT
  3. #define RTLD_NEXT ((void*)-1)
  4. #endif
  5. struct dyn_elf{
  6. unsigned long flags;
  7. struct elf_resolve * dyn;
  8. struct dyn_elf * next_handle; /* Used by dlopen et al. */
  9. struct dyn_elf * next;
  10. };
  11. struct elf_resolve{
  12. /* These entries must be in this order to be compatible with the interface used
  13. by gdb to obtain the list of symbols. */
  14. char * loadaddr;
  15. char * libname;
  16. unsigned long dynamic_addr;
  17. struct elf_resolve * next;
  18. struct elf_resolve * prev;
  19. /* Nothing after this address is used by gdb. */
  20. enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
  21. struct dyn_elf * symbol_scope;
  22. unsigned short usage_count;
  23. unsigned short int init_flag;
  24. unsigned int nbucket;
  25. unsigned long * elf_buckets;
  26. /*
  27. * These are only used with ELF style shared libraries
  28. */
  29. unsigned long nchain;
  30. unsigned long * chains;
  31. unsigned long dynamic_info[24];
  32. unsigned long dynamic_size;
  33. unsigned long n_phent;
  34. Elf32_Phdr * ppnt;
  35. };
  36. #if 0
  37. /*
  38. * The DT_DEBUG entry in the .dynamic section is given the address of this structure.
  39. * gdb can pick this up to obtain the correct list of loaded modules.
  40. */
  41. struct r_debug{
  42. int r_version;
  43. struct elf_resolve * link_map;
  44. unsigned long brk_fun;
  45. enum {RT_CONSISTENT, RT_ADD, RT_DELETE};
  46. unsigned long ldbase;
  47. };
  48. #endif
  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(char * libname);
  57. extern struct elf_resolve * _dl_add_elf_hash_table(char * libname,
  58. char * loadaddr, unsigned long * dynamic_info,
  59. unsigned long dynamic_addr, unsigned long dynamic_size);
  60. extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1,
  61. unsigned long instr_addr, struct elf_resolve * f_tpnt,
  62. int copyrel);
  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 DL_ERROR_NOFILE 1
  74. #define DL_ERROR_NOZERO 2
  75. #define DL_ERROR_NOTELF 3
  76. #define DL_ERROR_NOTMAGIC 4
  77. #define DL_ERROR_NOTDYN 5
  78. #define DL_ERROR_MMAP_FAILED 6
  79. #define DL_ERROR_NODYNAMIC 7
  80. #define DL_WRONG_RELOCS 8
  81. #define DL_BAD_HANDLE 9
  82. #define DL_NO_SYMBOL 10