reloc.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <endian.h>
  2. #if __BYTE_ORDER == __BIG_ENDIAN
  3. #define ENDIAN_SUFFIX "eb"
  4. #else
  5. #define ENDIAN_SUFFIX ""
  6. #endif
  7. #if __SH_FPU_ANY__ || __SH4__
  8. #define FP_SUFFIX ""
  9. #else
  10. #define FP_SUFFIX "-nofpu"
  11. #endif
  12. #if __SH_FDPIC__
  13. #define ABI_SUFFIX "-fdpic"
  14. #else
  15. #define ABI_SUFFIX ""
  16. #endif
  17. #define LDSO_ARCH "sh" ENDIAN_SUFFIX FP_SUFFIX ABI_SUFFIX
  18. #define TPOFF_K 8
  19. #define REL_SYMBOLIC R_SH_DIR32
  20. #define REL_OFFSET R_SH_REL32
  21. #define REL_GOT R_SH_GLOB_DAT
  22. #define REL_PLT R_SH_JMP_SLOT
  23. #define REL_RELATIVE R_SH_RELATIVE
  24. #define REL_COPY R_SH_COPY
  25. #define REL_DTPMOD R_SH_TLS_DTPMOD32
  26. #define REL_DTPOFF R_SH_TLS_DTPOFF32
  27. #define REL_TPOFF R_SH_TLS_TPOFF32
  28. #define DL_NOMMU_SUPPORT 1
  29. #if __SH_FDPIC__
  30. #define REL_FUNCDESC R_SH_FUNCDESC
  31. #define REL_FUNCDESC_VAL R_SH_FUNCDESC_VALUE
  32. #undef REL_RELATIVE
  33. #define DL_FDPIC 1
  34. #define FDPIC_CONSTDISP_FLAG 0x100
  35. #define CRTJMP(pc,sp) do { \
  36. register size_t r8 __asm__("r8") = ((size_t *)(sp))[-2]; \
  37. __asm__ __volatile__( "jmp @%0 ; mov %1,r15" \
  38. : : "r"(pc), "r"(sp), "r"(r8) : "memory" ); } while(0)
  39. #define GETFUNCSYM(fp, sym, got) __asm__ ( \
  40. "mov.l 1f,%0 ; add %1,%0 ; bra 2f ; nop ; .align 2 \n" \
  41. "1: .long " #sym "@GOTOFFFUNCDESC \n2:" \
  42. : "=&r"(*fp) : "r"(got) : "memory" )
  43. #else
  44. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  45. "jmp @%0 ; mov %1,r15" : : "r"(pc), "r"(sp) : "memory" )
  46. #endif