dl-sysdep.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* CRIS can never use Elf32_Rel relocations. */
  2. #define ELF_USES_RELOCA
  3. /* Initialization sequence for the GOT. */
  4. #define INIT_GOT(GOT_BASE,MODULE) \
  5. { \
  6. GOT_BASE[1] = (unsigned long) MODULE; \
  7. GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
  8. }
  9. /* Defined some magic numbers that this ld.so should accept. */
  10. #define MAGIC1 EM_CRIS
  11. #undef MAGIC2
  12. #define ELF_TARGET "CRIS"
  13. struct elf_resolve;
  14. extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
  15. /* Cheap modulo implementation, taken from arm/dl-sysdep.h. */
  16. static inline unsigned long
  17. cris_mod(unsigned long m, unsigned long p)
  18. {
  19. unsigned long i, t, inc;
  20. i = p;
  21. t = 0;
  22. while (!(i & (1 << 31))) {
  23. i <<= 1;
  24. t++;
  25. }
  26. t--;
  27. for (inc = t; inc > 2; inc--) {
  28. i = p << inc;
  29. if (i & (1 << 31))
  30. break;
  31. while (m >= i) {
  32. m -= i;
  33. i <<= 1;
  34. if (i & (1 << 31))
  35. break;
  36. if (i < p)
  37. break;
  38. }
  39. }
  40. while (m >= p)
  41. m -= p;
  42. return m;
  43. }
  44. #define do_rem(result, n, base) ((result) = cris_mod(n, base))
  45. /* 8192 bytes alignment */
  46. #define PAGE_ALIGN 0xffffe000
  47. #define ADDR_ALIGN 0x1fff
  48. #define OFFS_ALIGN 0xffffe000
  49. /* The union of reloc-type-classes where the reloc TYPE is a member.
  50. TYPE is in the class ELF_RTYPE_CLASS_PLT if it can describe a
  51. relocation for a PLT entry, that is, for which a PLT entry should not
  52. be allowed to define the value. The GNU linker for CRIS can merge a
  53. .got.plt entry (R_CRIS_JUMP_SLOT) with a .got entry (R_CRIS_GLOB_DAT),
  54. so we need to match both these reloc types.
  55. TYPE is in the class ELF_RTYPE_CLASS_NOCOPY if it should not be allowed
  56. to resolve to one of the main executable's symbols, as for a COPY
  57. reloc. */
  58. #define elf_machine_type_class(type) \
  59. ((((((type) == R_CRIS_JUMP_SLOT)) \
  60. || ((type) == R_CRIS_GLOB_DAT)) * ELF_RTYPE_CLASS_PLT) \
  61. | (((type) == R_CRIS_COPY) * ELF_RTYPE_CLASS_COPY))