reloc.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __RELOC_H__
  2. #define __RELOC_H__
  3. #define _GNU_SOURCE
  4. #include <endian.h>
  5. #if __mips_isa_rev >= 6
  6. #define ISA_SUFFIX "r6"
  7. #else
  8. #define ISA_SUFFIX ""
  9. #endif
  10. #if __BYTE_ORDER == __LITTLE_ENDIAN
  11. #define ENDIAN_SUFFIX "el"
  12. #else
  13. #define ENDIAN_SUFFIX ""
  14. #endif
  15. #ifdef __mips_soft_float
  16. #define FP_SUFFIX "-sf"
  17. #else
  18. #define FP_SUFFIX ""
  19. #endif
  20. #define LDSO_ARCH "mips64" ISA_SUFFIX ENDIAN_SUFFIX FP_SUFFIX
  21. #define TPOFF_K (-0x7000)
  22. #define REL_SYM_OR_REL 4611
  23. #define REL_PLT R_MIPS_JUMP_SLOT
  24. #define REL_COPY R_MIPS_COPY
  25. #define REL_DTPMOD R_MIPS_TLS_DTPMOD64
  26. #define REL_DTPOFF R_MIPS_TLS_DTPREL64
  27. #define REL_TPOFF R_MIPS_TLS_TPREL64
  28. #undef R_TYPE
  29. #undef R_SYM
  30. #undef R_INFO
  31. #define R_TYPE(x) (be64toh(x)&0x7fffffff)
  32. #define R_SYM(x) (be32toh(be64toh(x)>>32))
  33. #define R_INFO(s,t) (htobe64((uint64_t)htobe32(s)<<32 | (uint64_t)t))
  34. #define NEED_MIPS_GOT_RELOCS 1
  35. #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
  36. #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
  37. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  38. "move $sp,%1 ; jr %0" : : "r"(pc), "r"(sp) : "memory" )
  39. #define GETFUNCSYM(fp, sym, got) __asm__ ( \
  40. ".hidden " #sym "\n" \
  41. ".set push \n" \
  42. ".set noreorder \n" \
  43. ".align 8 \n" \
  44. " bal 1f \n" \
  45. " nop \n" \
  46. " .gpdword . \n" \
  47. " .gpdword " #sym " \n" \
  48. "1: ld %0, ($ra) \n" \
  49. " dsubu %0, $ra, %0 \n" \
  50. " ld $ra, 8($ra) \n" \
  51. " daddu %0, %0, $ra \n" \
  52. ".set pop \n" \
  53. : "=r"(*(fp)) : : "memory", "ra" )
  54. #endif