dl-hash.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
  4. *
  5. * GNU Lesser General Public License version 2.1 or later.
  6. */
  7. #ifndef _LD_HASH_H_
  8. #define _LD_HASH_H_
  9. #ifndef RTLD_NEXT
  10. #define RTLD_NEXT ((void*)-1)
  11. #endif
  12. struct init_fini {
  13. struct elf_resolve **init_fini;
  14. unsigned long nlist; /* Number of entries in init_fini */
  15. };
  16. struct dyn_elf {
  17. struct elf_resolve * dyn;
  18. struct dyn_elf * next_handle; /* Used by dlopen et al. */
  19. struct init_fini init_fini;
  20. struct dyn_elf * next;
  21. struct dyn_elf * prev;
  22. };
  23. struct elf_resolve {
  24. /* These entries must be in this order to be compatible with the interface used
  25. by gdb to obtain the list of symbols. */
  26. DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
  27. char *libname; /* Absolute file name object was found in. */
  28. ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
  29. struct elf_resolve * next;
  30. struct elf_resolve * prev;
  31. /* Nothing after this address is used by gdb. */
  32. enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
  33. struct dyn_elf * symbol_scope;
  34. unsigned short usage_count;
  35. unsigned short int init_flag;
  36. unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
  37. Elf_Symndx nbucket;
  38. #ifdef __LDSO_GNU_HASH_SUPPORT__
  39. /* Data needed to support GNU hash style */
  40. Elf32_Word l_gnu_bitmask_idxbits;
  41. Elf32_Word l_gnu_shift;
  42. const ElfW(Addr) *l_gnu_bitmask;
  43. union
  44. {
  45. const Elf32_Word *l_gnu_chain_zero;
  46. const Elf_Symndx *elf_buckets;
  47. };
  48. #else
  49. Elf_Symndx *elf_buckets;
  50. #endif
  51. struct init_fini_list *init_fini;
  52. struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
  53. /*
  54. * These are only used with ELF style shared libraries
  55. */
  56. Elf_Symndx nchain;
  57. #ifdef __LDSO_GNU_HASH_SUPPORT__
  58. union
  59. {
  60. const Elf32_Word *l_gnu_buckets;
  61. const Elf_Symndx *chains;
  62. };
  63. #else
  64. Elf_Symndx *chains;
  65. #endif
  66. unsigned long dynamic_info[DYNAMIC_SIZE];
  67. unsigned long n_phent;
  68. ElfW(Phdr) * ppnt;
  69. ElfW(Addr) relro_addr;
  70. size_t relro_size;
  71. dev_t st_dev; /* device */
  72. ino_t st_ino; /* inode */
  73. #ifdef __powerpc__
  74. /* this is used to store the address of relocation data words, so
  75. * we don't have to calculate it every time, which requires a divide */
  76. unsigned long data_words;
  77. #endif
  78. };
  79. #define RELOCS_DONE 0x000001
  80. #define JMP_RELOCS_DONE 0x000002
  81. #define INIT_FUNCS_CALLED 0x000004
  82. #define FINI_FUNCS_CALLED 0x000008
  83. #define DL_OPENED 0x000010
  84. extern struct dyn_elf * _dl_symbol_tables;
  85. extern struct elf_resolve * _dl_loaded_modules;
  86. extern struct dyn_elf * _dl_handles;
  87. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  88. DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info,
  89. unsigned long dynamic_addr, unsigned long dynamic_size);
  90. extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1,
  91. struct elf_resolve *mytpnt, int type_class);
  92. extern int _dl_linux_dynamic_link(void);
  93. extern char * _dl_library_path;
  94. extern char * _dl_not_lazy;
  95. static inline int _dl_symbol(char * name)
  96. {
  97. if(name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
  98. return 0;
  99. return 1;
  100. }
  101. #define LD_ERROR_NOFILE 1
  102. #define LD_ERROR_NOZERO 2
  103. #define LD_ERROR_NOTELF 3
  104. #define LD_ERROR_NOTMAGIC 4
  105. #define LD_ERROR_NOTDYN 5
  106. #define LD_ERROR_MMAP_FAILED 6
  107. #define LD_ERROR_NODYNAMIC 7
  108. #define LD_WRONG_RELOCS 8
  109. #define LD_BAD_HANDLE 9
  110. #define LD_NO_SYMBOL 10
  111. #endif /* _LD_HASH_H_ */