linuxelf.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 void * _dl_malloc(int size);
  11. extern int _dl_map_cache(void);
  12. extern int _dl_unmap_cache(void);
  13. int _dl_copy_fixups(struct dyn_elf * tpnt);
  14. extern int _dl_parse_copy_information(struct dyn_elf *rpnt,
  15. unsigned long rel_addr, unsigned long rel_size, int type);
  16. extern void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
  17. unsigned long rel_addr, unsigned long rel_size, int type);
  18. extern int _dl_parse_relocation_information(struct elf_resolve *tpnt,
  19. unsigned long rel_addr, unsigned long rel_size, int type);
  20. extern struct elf_resolve * _dl_load_shared_library(int secure,
  21. struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
  22. extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
  23. struct dyn_elf **rpnt, char *libname);
  24. extern int _dl_linux_resolve(void);
  25. #define ELF_CLASS ELFCLASS32
  26. #ifndef SVR4_BUGCOMPAT
  27. #define SVR4_BUGCOMPAT 1
  28. #endif
  29. #if ELF_CLASS == ELFCLASS32
  30. #define elfhdr Elf32_Ehdr
  31. #define elf_phdr Elf32_Phdr
  32. #define elf_note Elf32_Nhdr
  33. /*
  34. * Datatype of a relocation on this platform
  35. */
  36. #ifdef ELF_USES_RELOCA
  37. # define ELF_RELOC Elf32_Rela
  38. #else
  39. # define ELF_RELOC Elf32_Rel
  40. #endif
  41. #else
  42. #define elfhdr Elf64_Ehdr
  43. #define elf_phdr Elf64_Phdr
  44. #define elf_note Elf64_Nhdr
  45. /*
  46. * Datatype of a relocation on this platform
  47. */
  48. #ifdef ELF_USES_RELOCA
  49. # define ELF_RELOC Elf64_Rela
  50. #else
  51. # define ELF_RELOC Elf64_Rel
  52. #endif
  53. #endif
  54. /* Convert between the Linux flags for page protections and the
  55. ones specified in the ELF standard. */
  56. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  57. (((X) & PF_W) ? PROT_WRITE : 0) | \
  58. (((X) & PF_X) ? PROT_EXEC : 0))
  59. #endif /* LINUXELF_H */