dl-elf.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_ELF_LIBC5 2
  19. #define LIB_ELF_LIBC6 3
  20. #define LIB_ELF64 0x80
  21. /* Forward declarations for stuff defined in ld_hash.h */
  22. struct dyn_elf;
  23. struct elf_resolve;
  24. /* Definitions and prototypes for cache stuff */
  25. #ifdef USE_CACHE
  26. extern int _dl_map_cache(void);
  27. extern int _dl_unmap_cache(void);
  28. #define LDSO_CACHE_MAGIC "ld.so-"
  29. #define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
  30. #define LDSO_CACHE_VER "1.7.0"
  31. #define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1)
  32. typedef struct {
  33. char magic [LDSO_CACHE_MAGIC_LEN];
  34. char version [LDSO_CACHE_VER_LEN];
  35. int nlibs;
  36. } header_t;
  37. typedef struct {
  38. int flags;
  39. int sooffset;
  40. int liboffset;
  41. } libentry_t;
  42. #else
  43. static inline void _dl_map_cache(void) { }
  44. static inline void _dl_unmap_cache(void) { }
  45. #endif
  46. /* Function prototypes for non-static stuff in readelflib1.c */
  47. int _dl_copy_fixups(struct dyn_elf * tpnt);
  48. extern int _dl_parse_copy_information(struct dyn_elf *rpnt,
  49. unsigned long rel_addr, unsigned long rel_size, int type);
  50. extern void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
  51. unsigned long rel_addr, unsigned long rel_size, int type);
  52. extern int _dl_parse_relocation_information(struct elf_resolve *tpnt,
  53. unsigned long rel_addr, unsigned long rel_size, int type);
  54. extern struct elf_resolve * _dl_load_shared_library(int secure,
  55. struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
  56. extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
  57. struct dyn_elf **rpnt, char *libname);
  58. extern int _dl_linux_resolve(void);
  59. /*
  60. * Datatype of a relocation on this platform
  61. */
  62. #ifdef ELF_USES_RELOCA
  63. # define ELF_RELOC ElfW(Rela)
  64. #else
  65. # define ELF_RELOC ElfW(Rel)
  66. #endif
  67. /* Convert between the Linux flags for page protections and the
  68. ones specified in the ELF standard. */
  69. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  70. (((X) & PF_W) ? PROT_WRITE : 0) | \
  71. (((X) & PF_X) ? PROT_EXEC : 0))
  72. #endif /* LINUXELF_H */