ld_elf.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname);
  59. extern int _dl_linux_resolve(void);
  60. /*
  61. * Datatype of a relocation on this platform
  62. */
  63. #ifdef ELF_USES_RELOCA
  64. # define ELF_RELOC ElfW(Rela)
  65. #else
  66. # define ELF_RELOC ElfW(Rel)
  67. #endif
  68. /* Convert between the Linux flags for page protections and the
  69. ones specified in the ELF standard. */
  70. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  71. (((X) & PF_W) ? PROT_WRITE : 0) | \
  72. (((X) & PF_X) ? PROT_EXEC : 0))
  73. #endif /* LINUXELF_H */