dl-sysdep.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. /*
  7. * Define this if the system uses RELOCA.
  8. */
  9. #define ELF_USES_RELOCA
  10. /*
  11. * Get a pointer to the argv array. On many platforms this can be just
  12. * the address if the first argument, on other platforms we need to
  13. * do something a little more subtle here. We assume that argc is stored
  14. * at the word just below the argvp that we return here.
  15. */
  16. #define GET_ARGV(ARGVP, ARGS) __asm__("\tadd %%fp,68,%0\n" : "=r" (ARGVP));
  17. /*
  18. * Initialization sequence for a GOT. For the Sparc, this points to the
  19. * PLT, and we need to initialize a couple of the slots. The PLT should
  20. * look like:
  21. *
  22. * save %sp, -64, %sp
  23. * call _dl_linux_resolve
  24. * nop
  25. * .word implementation_dependent
  26. */
  27. #define INIT_GOT(GOT_BASE,MODULE) \
  28. { \
  29. GOT_BASE[0] = 0x9de3bfc0; /* save %sp, -64, %sp */ \
  30. GOT_BASE[1] = 0x40000000 | (((unsigned int) _dl_linux_resolve - (unsigned int) GOT_BASE - 4) >> 2); \
  31. GOT_BASE[2] = 0x01000000; /* nop */ \
  32. GOT_BASE[3] = (int) MODULE; \
  33. }
  34. /*
  35. * Here is a macro to perform a relocation. This is only used when
  36. * bootstrapping the dynamic loader.
  37. */
  38. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
  39. switch(ELF32_R_TYPE((RELP)->r_info)) { \
  40. case R_SPARC_32: \
  41. *REL = SYMBOL + (RELP)->r_addend; \
  42. break; \
  43. case R_SPARC_GLOB_DAT: \
  44. *REL = SYMBOL + (RELP)->r_addend; \
  45. break; \
  46. case R_SPARC_JMP_SLOT: \
  47. REL[1] = 0x03000000 | ((SYMBOL >> 10) & 0x3fffff); \
  48. REL[2] = 0x81c06000 | (SYMBOL & 0x3ff); \
  49. break; \
  50. case R_SPARC_NONE: \
  51. break; \
  52. case R_SPARC_WDISP30: \
  53. break; \
  54. case R_SPARC_RELATIVE: \
  55. *REL += (unsigned int) LOAD + (RELP)->r_addend; \
  56. break; \
  57. default: \
  58. _dl_exit(1); \
  59. }
  60. /*
  61. * Transfer control to the user's application, once the dynamic loader
  62. * is done. The crt calls atexit with $g1 if not null, so we need to
  63. * ensure that it contains NULL.
  64. */
  65. #define START() \
  66. __asm__ volatile ( \
  67. "add %%g0,%%g0,%%g1\n\t" \
  68. "jmpl %0, %%o7\n\t" \
  69. "restore %%g0,%%g0,%%g0\n\t" \
  70. : /*"=r" (status) */ : \
  71. "r" (_dl_elf_main): "g1", "o0", "o1")
  72. /* Here we define the magic numbers that this dynamic loader should accept */
  73. #define MAGIC1 EM_SPARC
  74. #undef MAGIC2
  75. /* Used for error messages */
  76. #define ELF_TARGET "Sparc"
  77. #ifndef COMPILE_ASM
  78. extern unsigned int _dl_linux_resolver(unsigned int reloc_entry,
  79. unsigned int * i);
  80. #endif
  81. /*
  82. * Define this if you want a dynamic loader that works on Solaris.
  83. */
  84. #define SOLARIS_COMPATIBLE
  85. /*
  86. * Define this because we do not want to call .udiv in the library.
  87. * Change on the plans -miguel:
  88. * We just statically link against .udiv. This is required
  89. * if we want to be able to run on Sun4c machines.
  90. */
  91. /* We now link .urem against this one */
  92. #ifdef USE_V8
  93. #define do_rem(result,n,base) ({ \
  94. volatile int __res; \
  95. __asm__("mov %%g0,%%Y\n\t" \
  96. "sdiv %2,%3,%%l6\n\t" \
  97. "smul %%l6,%3,%%l6\n\t" \
  98. "sub %2,%%l6,%0\n\t" \
  99. :"=r" (result),"=r" (__res):"r" (n),"r"(base) : "l6" ); __res; })
  100. #else
  101. #define do_rem(a,b,c) a = _dl_urem (b,c);
  102. #endif
  103. /*
  104. * dbx wants the binder to have a specific name. Mustn't disappoint it.
  105. */
  106. #ifdef SOLARIS_COMPATIBLE
  107. #define _dl_linux_resolve _elf_rtbndr
  108. #endif