ld_sysdep.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #define 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_SH_REL32: \
  33. *(REL) += (RELP)->r_addend - (LOAD); \
  34. break; \
  35. case R_SH_DIR32: \
  36. *(REL) += (SYMBOL) + (RELP)->r_addend; \
  37. break; \
  38. case R_SH_RELATIVE: \
  39. *(REL) += (LOAD); \
  40. break; \
  41. case R_SH_NONE: \
  42. break; \
  43. default: \
  44. SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc type "); \
  45. SEND_NUMBER_STDERR(ELF32_R_TYPE((RELP)->r_info), 1); \
  46. SEND_STDERR("REL, SYMBOL, LOAD: "); \
  47. SEND_ADDRESS_STDERR(REL, 0); \
  48. SEND_STDERR(", "); \
  49. SEND_ADDRESS_STDERR(SYMBOL, 0); \
  50. SEND_STDERR(", "); \
  51. SEND_ADDRESS_STDERR(LOAD, 1); \
  52. _dl_exit(1); \
  53. }
  54. /*
  55. * Transfer control to the user's application, once the dynamic loader
  56. * is done. This routine has to exit the current function, then
  57. * call the _dl_elf_main function.
  58. */
  59. #define START() return _dl_elf_main;
  60. /* Here we define the magic numbers that this dynamic loader should accept */
  61. #define MAGIC1 EM_SH
  62. #undef MAGIC2
  63. /* Used for error messages */
  64. #define ELF_TARGET "sh"
  65. struct elf_resolve;
  66. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  67. #define do_rem(result, n, base) result = (n % base)
  68. /* 4096 bytes alignment */
  69. #define PAGE_ALIGN 0xfffff000
  70. #define ADDR_ALIGN 0xfff
  71. #define OFFS_ALIGN 0x7ffff000