ldsodefs.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #ifndef __LDSODEFS_H__
  4. #define __LDSODEFS_H__
  5. #include "elf.h"
  6. /* We use this macro to refer to ELF types independent of the native wordsize.
  7. `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
  8. #define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
  9. #define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
  10. #define _ElfW_1(e,w,t) e##w##t
  11. /* We use this macro to refer to ELF types independent of the native wordsize.
  12. `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
  13. #define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type)
  14. /* We don't like the link_map form ld.so. This macro will be redefined */
  15. #define D_PTR(sym) (sym)->d_un.d_ptr
  16. /* ELF uses the PF_x macros to specify the segment permissions, mmap
  17. uses PROT_xxx. In most cases the three macros have the values 1, 2,
  18. and 3 but not in a matching order. The following macros allows
  19. converting from the PF_x values to PROT_xxx values. */
  20. #define PF_TO_PROT \
  21. ((PROT_READ << (PF_R * 4)) \
  22. | (PROT_WRITE << (PF_W * 4)) \
  23. | (PROT_EXEC << (PF_X * 4)) \
  24. | ((PROT_READ | PROT_WRITE) << ((PF_R | PF_W) * 4)) \
  25. | ((PROT_READ | PROT_EXEC) << ((PF_R | PF_X) * 4)) \
  26. | ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4) \
  27. | ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4)))
  28. #endif /* ldsodefs.h */