linuxelf.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef LINUXELF_H
  2. #define LINUXELF_H
  3. #include <sys/types.h>
  4. #include "ld_sysdep.h" /* before elf.h to get ELF_USES_RELOCA right */
  5. #include <elf.h>
  6. /* Forward declarations for stuff defined in hash.h */
  7. struct dyn_elf;
  8. struct elf_resolve;
  9. /* Some function prototypes */
  10. extern int _dl_map_cache(void);
  11. extern int _dl_unmap_cache(void);
  12. int _dl_copy_fixups(struct dyn_elf * tpnt);
  13. extern int _dl_parse_copy_information(struct dyn_elf *rpnt,
  14. unsigned long rel_addr, unsigned long rel_size, int type);
  15. extern void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
  16. unsigned long rel_addr, unsigned long rel_size, int type);
  17. extern int _dl_parse_relocation_information(struct elf_resolve *tpnt,
  18. unsigned long rel_addr, unsigned long rel_size, int type);
  19. extern struct elf_resolve * _dl_load_shared_library(int secure,
  20. struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
  21. extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
  22. struct dyn_elf **rpnt, char *libname);
  23. extern int _dl_linux_resolve(void);
  24. #define ELF_CLASS ELFCLASS32
  25. #if ELF_CLASS == ELFCLASS32
  26. #define elfhdr Elf32_Ehdr
  27. #define elf_phdr Elf32_Phdr
  28. #define elf_note Elf32_Nhdr
  29. /*
  30. * Datatype of a relocation on this platform
  31. */
  32. #ifdef ELF_USES_RELOCA
  33. # define ELF_RELOC Elf32_Rela
  34. #else
  35. # define ELF_RELOC Elf32_Rel
  36. #endif
  37. #else
  38. #define elfhdr Elf64_Ehdr
  39. #define elf_phdr Elf64_Phdr
  40. #define elf_note Elf64_Nhdr
  41. /*
  42. * Datatype of a relocation on this platform
  43. */
  44. #ifdef ELF_USES_RELOCA
  45. # define ELF_RELOC Elf64_Rela
  46. #else
  47. # define ELF_RELOC Elf64_Rel
  48. #endif
  49. #endif
  50. /* Convert between the Linux flags for page protections and the
  51. ones specified in the ELF standard. */
  52. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  53. (((X) & PF_W) ? PROT_WRITE : 0) | \
  54. (((X) & PF_X) ? PROT_EXEC : 0))
  55. #endif /* LINUXELF_H */