dl-hash.h 3.0 KB

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