ldsodefs.h 1.5 KB

123456789101112131415161718192021222324252627282930
  1. #ifndef __LDSODEFS_H__
  2. #define __LDSODEFS_H__
  3. #include "elf.h"
  4. /* We use this macro to refer to ELF types independent of the native wordsize.
  5. `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
  6. #define ElfW(type) _ElfW(Elf, __ELF_NATIVE_CLASS, type)
  7. #define _ElfW(e, w, t) _ElfW_1(e, w, _##t)
  8. #define _ElfW_1(e, w, t) e##w##t
  9. /* We use this macro to refer to ELF types independent of the native wordsize.
  10. `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
  11. #define ELFW(type) _ElfW(ELF, __ELF_NATIVE_CLASS, type)
  12. /* We don't like the link_map form ld.so. This macro will be redefined */
  13. #define D_PTR(sym) (sym)->d_un.d_ptr
  14. /* ELF uses the PF_x macros to specify the segment permissions, mmap
  15. uses PROT_xxx. In most cases the three macros have the values 1, 2,
  16. and 3 but not in a matching order. The following macros allows
  17. converting from the PF_x values to PROT_xxx values. */
  18. #define PF_TO_PROT \
  19. ((PROT_READ << (PF_R * 4)) | (PROT_WRITE << (PF_W * 4)) | (PROT_EXEC << (PF_X * 4)) | \
  20. ((PROT_READ | PROT_WRITE) << ((PF_R | PF_W) * 4)) | \
  21. ((PROT_READ | PROT_EXEC) << ((PF_R | PF_X) * 4)) | \
  22. ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4) | \
  23. ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4)))
  24. #endif /* ldsodefs.h */