dl-elf.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef LINUXELF_H
  2. #define LINUXELF_H
  3. #include <dl-string.h> /* before elf.h to get ELF_USES_RELOCA right */
  4. #include <elf.h>
  5. #include <link.h>
  6. /* Forward declarations for stuff defined in ld_hash.h */
  7. struct dyn_elf;
  8. struct elf_resolve;
  9. #include <dl-defs.h>
  10. #ifdef __LDSO_CACHE_SUPPORT__
  11. extern int _dl_map_cache(void);
  12. extern int _dl_unmap_cache(void);
  13. #else
  14. static inline void _dl_map_cache(void) { }
  15. static inline void _dl_unmap_cache(void) { }
  16. #endif
  17. /* Function prototypes for non-static stuff in readelflib1.c */
  18. extern int _dl_parse_copy_information(struct dyn_elf *rpnt,
  19. unsigned long rel_addr, unsigned long rel_size);
  20. extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
  21. unsigned long rel_addr, unsigned long rel_size);
  22. extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
  23. unsigned long rel_addr, unsigned long rel_size);
  24. extern struct elf_resolve * _dl_load_shared_library(int secure,
  25. struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
  26. int trace_loaded_objects);
  27. extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
  28. struct dyn_elf **rpnt, char *libname);
  29. extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
  30. int trace_loaded_objects);
  31. extern int _dl_linux_resolve(void);
  32. extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
  33. /*
  34. * Datatype of a relocation on this platform
  35. */
  36. #ifdef ELF_USES_RELOCA
  37. # define ELF_RELOC ElfW(Rela)
  38. # define DT_RELOC_TABLE_ADDR DT_RELA
  39. # define DT_RELOC_TABLE_SIZE DT_RELASZ
  40. # define UNSUPPORTED_RELOC_TYPE DT_REL
  41. # define UNSUPPORTED_RELOC_STR "REL"
  42. #else
  43. # define ELF_RELOC ElfW(Rel)
  44. # define DT_RELOC_TABLE_ADDR DT_REL
  45. # define DT_RELOC_TABLE_SIZE DT_RELSZ
  46. # define UNSUPPORTED_RELOC_TYPE DT_RELA
  47. # define UNSUPPORTED_RELOC_STR "RELA"
  48. #endif
  49. /* Reloc type classes as returned by elf_machine_type_class().
  50. ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by
  51. some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be
  52. satisfied by any symbol in the executable. Some architectures do
  53. not support copy relocations. In this case we define the macro to
  54. zero so that the code for handling them gets automatically optimized
  55. out. */
  56. #ifdef DL_NO_COPY_RELOCS
  57. # define ELF_RTYPE_CLASS_COPY (0x0)
  58. #else
  59. # define ELF_RTYPE_CLASS_COPY (0x2)
  60. #endif
  61. #define ELF_RTYPE_CLASS_PLT (0x1)
  62. /* Convert between the Linux flags for page protections and the
  63. ones specified in the ELF standard. */
  64. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  65. (((X) & PF_W) ? PROT_WRITE : 0) | \
  66. (((X) & PF_X) ? PROT_EXEC : 0))
  67. #endif /* LINUXELF_H */