dl-elf.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef LINUXELF_H
  2. #define LINUXELF_H
  3. #include <ld_sysdep.h> /* before elf.h to get ELF_USES_RELOCA right */
  4. #include <elf.h>
  5. #include <link.h>
  6. #ifdef DEBUG
  7. # define LDSO_CONF "../util/ld.so.conf"
  8. # define LDSO_CACHE "../util/ld.so.cache"
  9. # define LDSO_PRELOAD "../util/ld.so.preload"
  10. #else
  11. # define LDSO_CONF UCLIBC_TARGET_PREFIX "etc/ld.so.conf"
  12. # define LDSO_CACHE UCLIBC_TARGET_PREFIX "etc/ld.so.cache"
  13. # define LDSO_PRELOAD UCLIBC_TARGET_PREFIX "etc/ld.so.preload"
  14. #endif
  15. #define LIB_ANY -1
  16. #define LIB_DLL 0
  17. #define LIB_ELF 1
  18. #define LIB_ELF64 0x80
  19. #define LIB_ELF_LIBC5 2
  20. #define LIB_ELF_LIBC6 3
  21. #define LIB_ELF_LIBC0 4
  22. /* Forward declarations for stuff defined in ld_hash.h */
  23. struct dyn_elf;
  24. struct elf_resolve;
  25. /* Definitions and prototypes for cache stuff */
  26. #ifdef USE_CACHE
  27. extern int _dl_map_cache(void);
  28. extern int _dl_unmap_cache(void);
  29. #define LDSO_CACHE_MAGIC "ld.so-"
  30. #define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
  31. #define LDSO_CACHE_VER "1.7.0"
  32. #define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1)
  33. typedef struct {
  34. char magic [LDSO_CACHE_MAGIC_LEN];
  35. char version [LDSO_CACHE_VER_LEN];
  36. int nlibs;
  37. } header_t;
  38. typedef struct {
  39. int flags;
  40. int sooffset;
  41. int liboffset;
  42. } libentry_t;
  43. #else
  44. static inline void _dl_map_cache(void) { }
  45. static inline void _dl_unmap_cache(void) { }
  46. #endif
  47. /* Function prototypes for non-static stuff in readelflib1.c */
  48. int _dl_copy_fixups(struct dyn_elf * tpnt);
  49. extern int _dl_parse_copy_information(struct dyn_elf *rpnt,
  50. unsigned long rel_addr, unsigned long rel_size, int type);
  51. extern void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
  52. unsigned long rel_addr, unsigned long rel_size, int type);
  53. extern int _dl_parse_relocation_information(struct elf_resolve *tpnt,
  54. unsigned long rel_addr, unsigned long rel_size, int type);
  55. extern struct elf_resolve * _dl_load_shared_library(int secure,
  56. struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
  57. extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
  58. struct dyn_elf **rpnt, char *libname);
  59. extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname);
  60. extern int _dl_linux_resolve(void);
  61. /*
  62. * Datatype of a relocation on this platform
  63. */
  64. #ifdef ELF_USES_RELOCA
  65. # define ELF_RELOC ElfW(Rela)
  66. #else
  67. # define ELF_RELOC ElfW(Rel)
  68. #endif
  69. /* Convert between the Linux flags for page protections and the
  70. ones specified in the ELF standard. */
  71. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  72. (((X) & PF_W) ? PROT_WRITE : 0) | \
  73. (((X) & PF_X) ? PROT_EXEC : 0))
  74. #endif /* LINUXELF_H */