dl-sysdep.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* CRIS can never use Elf32_Rel relocations. */
  2. #define ELF_USES_RELOCA
  3. /*
  4. * Get a pointer to the argv array. On many platforms this can be just
  5. * the address if the first argument, on other platforms we need to
  6. * do something a little more subtle here.
  7. */
  8. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *) ARGS)
  9. /*
  10. * Initialization sequence for a GOT.
  11. */
  12. #define INIT_GOT(GOT_BASE,MODULE) \
  13. { \
  14. GOT_BASE[1] = (unsigned long) MODULE; \
  15. GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
  16. }
  17. /*
  18. * Here is a macro to perform a relocation. This is only used when
  19. * bootstrapping the dynamic loader. RELP is the relocation that we
  20. * are performing, REL is the pointer to the address we are relocating.
  21. * SYMBOL is the symbol involved in the relocation, and LOAD is the
  22. * load address.
  23. */
  24. #define PERFORM_BOOTSTRAP_RELOC(RELP, REL, SYMBOL, LOAD) \
  25. switch (ELF32_R_TYPE((RELP)->r_info)) { \
  26. case R_CRIS_GLOB_DAT: \
  27. case R_CRIS_JUMP_SLOT: \
  28. case R_CRIS_32: \
  29. *REL = SYMBOL; \
  30. break; \
  31. case R_CRIS_16_PCREL: \
  32. *(short *) *REL = SYMBOL + (RELP)->r_addend - *REL - 2; \
  33. break; \
  34. case R_CRIS_32_PCREL: \
  35. *REL = SYMBOL + (RELP)->r_addend - *REL - 4; \
  36. break; \
  37. case R_CRIS_NONE: \
  38. break; \
  39. case R_CRIS_RELATIVE: \
  40. *REL = (unsigned long) LOAD + (RELP)->r_addend; \
  41. break; \
  42. default: \
  43. _dl_exit(1); \
  44. break; \
  45. }
  46. /*
  47. * Transfer control to the user's application once the dynamic loader
  48. * is done. This routine has to exit the current function, then call
  49. * _dl_elf_main.
  50. */
  51. #define START() __asm__ volatile ("moveq 0,$r8\n\t" \
  52. "move $r8,$srp\n\t" \
  53. "move.d %1,$sp\n\t" \
  54. "jump %0\n\t" \
  55. : : "r" (_dl_elf_main), "r" (args))
  56. /* Defined some magic numbers that this ld.so should accept. */
  57. #define MAGIC1 EM_CRIS
  58. #undef MAGIC2
  59. #define ELF_TARGET "CRIS"
  60. struct elf_resolve;
  61. extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
  62. /* Cheap modulo implementation, taken from arm/ld_sysdep.h. */
  63. static inline unsigned long
  64. cris_mod(unsigned long m, unsigned long p)
  65. {
  66. unsigned long i, t, inc;
  67. i = p;
  68. t = 0;
  69. while (!(i & (1 << 31))) {
  70. i <<= 1;
  71. t++;
  72. }
  73. t--;
  74. for (inc = t; inc > 2; inc--) {
  75. i = p << inc;
  76. if (i & (1 << 31))
  77. break;
  78. while (m >= i) {
  79. m -= i;
  80. i <<= 1;
  81. if (i & (1 << 31))
  82. break;
  83. if (i < p)
  84. break;
  85. }
  86. }
  87. while (m >= p)
  88. m -= p;
  89. return m;
  90. }
  91. #define do_rem(result, n, base) result = cris_mod(n, base);
  92. /* 8192 bytes alignment */
  93. #define PAGE_ALIGN 0xffffe000
  94. #define ADDR_ALIGN 0x1fff
  95. #define OFFS_ALIGN 0xffffe000