ld_sysdep.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /*
  6. * Define this if the system uses RELOCA.
  7. */
  8. #undef ELF_USES_RELOCA
  9. /*
  10. * Get a pointer to the argv array. On many platforms this can be just
  11. * the address if the first argument, on other platforms we need to
  12. * do something a little more subtle here.
  13. */
  14. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned int*) & ARGS)
  15. /*
  16. * Get the address of the Global offset table. This must be absolute, not
  17. * relative.
  18. */
  19. #define GET_GOT(X) __asm__("\tmovl %%ebx,%0\n\t" : "=a" (X))
  20. /*
  21. * Initialization sequence for a GOT.
  22. */
  23. #define INIT_GOT(GOT_BASE,MODULE) \
  24. { \
  25. GOT_BASE[2] = (int) _dl_linux_resolve; \
  26. GOT_BASE[1] = (int) MODULE; \
  27. }
  28. /*
  29. * Here is a macro to perform a relocation. This is only used when
  30. * bootstrapping the dynamic loader. RELP is the relocation that we
  31. * are performing, REL is the pointer to the address we are relocating.
  32. * SYMBOL is the symbol involved in the relocation, and LOAD is the
  33. * load address.
  34. */
  35. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
  36. switch(ELF32_R_TYPE((RELP)->r_info)){ \
  37. case R_386_32: \
  38. *REL += SYMBOL; \
  39. break; \
  40. case R_386_PC32: \
  41. *REL += SYMBOL - (unsigned int) REL; \
  42. break; \
  43. case R_386_GLOB_DAT: \
  44. case R_386_JMP_SLOT: \
  45. *REL = SYMBOL; \
  46. break; \
  47. case R_386_RELATIVE: \
  48. *REL += (unsigned int) LOAD; \
  49. break; \
  50. default: \
  51. _dl_exit(1); \
  52. }
  53. /*
  54. * Transfer control to the user's application, once the dynamic loader
  55. * is done.
  56. */
  57. #define START() \
  58. __asm__ volatile ("leave\n\t" \
  59. "jmp *%%eax\n\t" \
  60. : "=a" (status) : \
  61. "d" (_dl_interpreter_exit), "a" (_dl_elf_main))
  62. /* Here we define the magic numbers that this dynamic loader should accept */
  63. #define MAGIC1 EM_386
  64. #define MAGIC2 EM_486
  65. /* Used for error messages */
  66. #define ELF_TARGET "386/486"
  67. extern unsigned int _dl_linux_resolver(int dummy, int i);
  68. #define do_rem(result, n, base) result = (n % base)