ld_sysdep.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 long*) & 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 long) 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 long) 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. This routine has to exit the current function, then
  56. * call the _dl_elf_main function.
  57. */
  58. #define START() \
  59. __asm__ volatile ("leave\n\t" \
  60. "jmp *%%eax\n\t" \
  61. : "=a" (status) : "a" (_dl_elf_main))
  62. /* Here we define the magic numbers that this dynamic loader should accept */
  63. #define MAGIC1 EM_386
  64. #undef MAGIC2
  65. /* Used for error messages */
  66. #define ELF_TARGET "386"
  67. struct elf_resolve;
  68. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  69. #define do_rem(result, n, base) result = (n % base)