dl-sysdep.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 LINUXBIN
  6. /* Define this if the system uses RELOCA. */
  7. #define ELF_USES_RELOCA
  8. /*
  9. * Initialization sequence for a GOT. For the Sparc, this points to the
  10. * PLT, and we need to initialize a couple of the slots. The PLT should
  11. * look like:
  12. *
  13. * save %sp, -64, %sp
  14. * call _dl_linux_resolve
  15. * nop
  16. * .word implementation_dependent
  17. */
  18. #define INIT_GOT(GOT_BASE,MODULE) \
  19. { \
  20. GOT_BASE[0] = 0x9de3bfc0; /* save %sp, -64, %sp */ \
  21. GOT_BASE[1] = 0x40000000 | (((unsigned int) _dl_linux_resolve - (unsigned int) GOT_BASE - 4) >> 2); \
  22. GOT_BASE[2] = 0x01000000; /* nop */ \
  23. GOT_BASE[3] = (int) MODULE; \
  24. }
  25. /* Here we define the magic numbers that this dynamic loader should accept */
  26. #define MAGIC1 EM_SPARC
  27. #undef MAGIC2
  28. /* Used for error messages */
  29. #define ELF_TARGET "Sparc"
  30. #ifndef COMPILE_ASM
  31. extern unsigned int _dl_linux_resolver(unsigned int reloc_entry,
  32. unsigned int * i);
  33. #endif
  34. /*
  35. * Define this if you want a dynamic loader that works on Solaris.
  36. */
  37. #ifndef __linux__
  38. #define SOLARIS_COMPATIBLE
  39. #endif
  40. #ifndef COMPILE_ASM
  41. /* Cheap modulo implementation, taken from arm/ld_sysdep.h. */
  42. static inline unsigned long
  43. sparc_mod(unsigned long m, unsigned long p)
  44. {
  45. unsigned long i, t, inc;
  46. i = p;
  47. t = 0;
  48. while (!(i & (1 << 31))) {
  49. i <<= 1;
  50. t++;
  51. }
  52. t--;
  53. for (inc = t; inc > 2; inc--) {
  54. i = p << inc;
  55. if (i & (1 << 31))
  56. break;
  57. while (m >= i) {
  58. m -= i;
  59. i <<= 1;
  60. if (i & (1 << 31))
  61. break;
  62. if (i < p)
  63. break;
  64. }
  65. }
  66. while (m >= p)
  67. m -= p;
  68. return m;
  69. }
  70. #define do_rem(result, n, base) ((result) = sparc_mod(n, base))
  71. #endif
  72. /*
  73. * dbx wants the binder to have a specific name. Mustn't disappoint it.
  74. */
  75. #ifdef SOLARIS_COMPATIBLE
  76. #define _dl_linux_resolve _elf_rtbndr
  77. #endif
  78. /* 4096 bytes alignment */
  79. /* ...but 8192 is required for mmap() on sparc64 kernel */
  80. #define PAGE_ALIGN 0xffffe000
  81. #define ADDR_ALIGN 0x1fff
  82. #define OFFS_ALIGN 0x7fffe000
  83. /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
  84. PLT entries should not be allowed to define the value.
  85. ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
  86. of the main executable's symbols, as for a COPY reloc. */
  87. #define elf_machine_type_class(type) \
  88. ((((type) == R_SPARC_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
  89. | (((type) == R_SPARC_COPY) * ELF_RTYPE_CLASS_COPY))
  90. /* The SPARC overlaps DT_RELA and DT_PLTREL. */
  91. #define ELF_MACHINE_PLTREL_OVERLAP 1