ld_sysdep.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. * Initialization sequence for a GOT.
  17. */
  18. #define INIT_GOT(GOT_BASE,MODULE) \
  19. { \
  20. GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
  21. GOT_BASE[1] = (unsigned long) MODULE; \
  22. }
  23. /*
  24. * Here is a macro to perform a relocation. This is only used when
  25. * bootstrapping the dynamic loader. RELP is the relocation that we
  26. * are performing, REL is the pointer to the address we are relocating.
  27. * SYMBOL is the symbol involved in the relocation, and LOAD is the
  28. * load address.
  29. */
  30. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
  31. switch(ELF32_R_TYPE((RELP)->r_info)){ \
  32. case R_386_32: \
  33. *REL += SYMBOL; \
  34. break; \
  35. case R_386_PC32: \
  36. *REL += SYMBOL - (unsigned long) REL; \
  37. break; \
  38. case R_386_GLOB_DAT: \
  39. case R_386_JMP_SLOT: \
  40. *REL = SYMBOL; \
  41. break; \
  42. case R_386_RELATIVE: \
  43. *REL += (unsigned long) LOAD; \
  44. break; \
  45. default: \
  46. _dl_exit(1); \
  47. }
  48. /*
  49. * Transfer control to the user's application, once the dynamic loader
  50. * is done. This routine has to exit the current function, then
  51. * call the _dl_elf_main function.
  52. */
  53. #define START() \
  54. __asm__ volatile ("leave\n\t" \
  55. "jmp *%%eax\n\t" \
  56. : "=a" (status) : "a" (_dl_elf_main))
  57. /* Here we define the magic numbers that this dynamic loader should accept */
  58. #define MAGIC1 EM_386
  59. #undef MAGIC2
  60. /* Used for error messages */
  61. #define ELF_TARGET "386"
  62. struct elf_resolve;
  63. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  64. #define do_rem(result, n, base) result = (n % base)