dl-sysdep.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Various assmbly language/system dependent hacks that are required
  3. * so that we can minimize the amount of platform specific code.
  4. */
  5. /* Define this if the system uses RELOCA. */
  6. #define ELF_USES_RELOCA
  7. /*
  8. * Initialization sequence for a GOT.
  9. */
  10. #define INIT_GOT(GOT_BASE,MODULE) \
  11. { \
  12. GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
  13. GOT_BASE[1] = (unsigned long) (MODULE); \
  14. }
  15. /* Here we define the magic numbers that this dynamic loader should accept */
  16. #define MAGIC1 EM_SH
  17. #undef MAGIC2
  18. /* Used for error messages */
  19. #define ELF_TARGET "sh"
  20. struct elf_resolve;
  21. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  22. static __inline__ unsigned int
  23. _dl_urem(unsigned int n, unsigned int base)
  24. {
  25. int res;
  26. __asm__ (""\
  27. "mov #0, r0\n\t" \
  28. "div0u\n\t" \
  29. "" \
  30. "! get one bit from the msb of the numerator into the T\n\t" \
  31. "! bit and divide it by whats in %2. Put the answer bit\n\t" \
  32. "! into the T bit so it can come out again at the bottom\n\t" \
  33. "" \
  34. "rotcl %1 ; div1 %2, r0\n\t" \
  35. "rotcl %1 ; div1 %2, r0\n\t" \
  36. "rotcl %1 ; div1 %2, r0\n\t" \
  37. "rotcl %1 ; div1 %2, r0\n\t" \
  38. "rotcl %1 ; div1 %2, r0\n\t" \
  39. "rotcl %1 ; div1 %2, r0\n\t" \
  40. "rotcl %1 ; div1 %2, r0\n\t" \
  41. "rotcl %1 ; div1 %2, r0\n\t" \
  42. "" \
  43. "rotcl %1 ; div1 %2, r0\n\t" \
  44. "rotcl %1 ; div1 %2, r0\n\t" \
  45. "rotcl %1 ; div1 %2, r0\n\t" \
  46. "rotcl %1 ; div1 %2, r0\n\t" \
  47. "rotcl %1 ; div1 %2, r0\n\t" \
  48. "rotcl %1 ; div1 %2, r0\n\t" \
  49. "rotcl %1 ; div1 %2, r0\n\t" \
  50. "rotcl %1 ; div1 %2, r0\n\t" \
  51. "" \
  52. "rotcl %1 ; div1 %2, r0\n\t" \
  53. "rotcl %1 ; div1 %2, r0\n\t" \
  54. "rotcl %1 ; div1 %2, r0\n\t" \
  55. "rotcl %1 ; div1 %2, r0\n\t" \
  56. "rotcl %1 ; div1 %2, r0\n\t" \
  57. "rotcl %1 ; div1 %2, r0\n\t" \
  58. "rotcl %1 ; div1 %2, r0\n\t" \
  59. "rotcl %1 ; div1 %2, r0\n\t" \
  60. "" \
  61. "rotcl %1 ; div1 %2, r0\n\t" \
  62. "rotcl %1 ; div1 %2, r0\n\t" \
  63. "rotcl %1 ; div1 %2, r0\n\t" \
  64. "rotcl %1 ; div1 %2, r0\n\t" \
  65. "rotcl %1 ; div1 %2, r0\n\t" \
  66. "rotcl %1 ; div1 %2, r0\n\t" \
  67. "rotcl %1 ; div1 %2, r0\n\t" \
  68. "rotcl %1 ; div1 %2, r0\n\t" \
  69. "rotcl %1\n\t"
  70. : "=r" (res)
  71. : "0" (n), "r" (base)
  72. : "r0","cc");
  73. return n - (base * res);
  74. }
  75. #define do_rem(result, n, base) ((result) = _dl_urem((n), (base)))
  76. /* 4096 bytes alignment */
  77. #define PAGE_ALIGN 0xfffff000
  78. #define ADDR_ALIGN 0xfff
  79. #define OFFS_ALIGN 0x7ffff000
  80. /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
  81. TLS variable, so undefined references should not be allowed to
  82. define the value.
  83. ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
  84. of the main executable's symbols, as for a COPY reloc. */
  85. #define elf_machine_type_class(type) \
  86. ((((type) == R_SH_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
  87. | (((type) == R_SH_COPY) * ELF_RTYPE_CLASS_COPY))