dl-elf.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
  19. unsigned long rel_addr, unsigned long rel_size);
  20. extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
  21. unsigned long rel_addr, unsigned long rel_size);
  22. extern struct elf_resolve * _dl_load_shared_library(int secure,
  23. struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
  24. int trace_loaded_objects);
  25. extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
  26. struct dyn_elf **rpnt, char *libname);
  27. extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
  28. int trace_loaded_objects);
  29. extern int _dl_linux_resolve(void);
  30. extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
  31. /*
  32. * Datatype of a relocation on this platform
  33. */
  34. #ifdef ELF_USES_RELOCA
  35. # define ELF_RELOC ElfW(Rela)
  36. # define DT_RELOC_TABLE_ADDR DT_RELA
  37. # define DT_RELOC_TABLE_SIZE DT_RELASZ
  38. # define UNSUPPORTED_RELOC_TYPE DT_REL
  39. # define UNSUPPORTED_RELOC_STR "REL"
  40. #else
  41. # define ELF_RELOC ElfW(Rel)
  42. # define DT_RELOC_TABLE_ADDR DT_REL
  43. # define DT_RELOC_TABLE_SIZE DT_RELSZ
  44. # define UNSUPPORTED_RELOC_TYPE DT_RELA
  45. # define UNSUPPORTED_RELOC_STR "RELA"
  46. #endif
  47. /* Reloc type classes as returned by elf_machine_type_class().
  48. ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by
  49. some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be
  50. satisfied by any symbol in the executable. Some architectures do
  51. not support copy relocations. In this case we define the macro to
  52. zero so that the code for handling them gets automatically optimized
  53. out. */
  54. #ifdef DL_NO_COPY_RELOCS
  55. # define ELF_RTYPE_CLASS_COPY (0x0)
  56. #else
  57. # define ELF_RTYPE_CLASS_COPY (0x2)
  58. #endif
  59. #define ELF_RTYPE_CLASS_PLT (0x1)
  60. /* Convert between the Linux flags for page protections and the
  61. ones specified in the ELF standard. */
  62. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  63. (((X) & PF_W) ? PROT_WRITE : 0) | \
  64. (((X) & PF_X) ? PROT_EXEC : 0))
  65. #endif /* LINUXELF_H */