ld_sysdep.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_ARM_ABS32: \
  33. *REL += SYMBOL; \
  34. break; \
  35. case R_ARM_PC24: \
  36. { long newvalue, topbits; \
  37. unsigned long addend = *REL & 0x00ffffff; \
  38. if (addend & 0x00800000) addend |= 0xff000000; \
  39. newvalue=SYMBOL-(unsigned long)REL+(addend<<2); \
  40. topbits = newvalue & 0xfe000000; \
  41. if (topbits!=0xfe000000&&topbits!=0x00000000){ \
  42. newvalue = fix_bad_pc24(REL, SYMBOL) \
  43. -(unsigned long)REL+(addend<<2); \
  44. topbits = newvalue & 0xfe000000; \
  45. if (topbits!=0xfe000000&&topbits!=0x00000000){ \
  46. SEND_STDERR("R_ARM_PC24 relocation out of range\n");\
  47. _dl_exit(1); } } \
  48. newvalue>>=2; \
  49. SYMBOL=(*REL&0xff000000)|(newvalue & 0x00ffffff); \
  50. *REL=SYMBOL; \
  51. } \
  52. break; \
  53. case R_ARM_GLOB_DAT: \
  54. case R_ARM_JUMP_SLOT: \
  55. *REL = SYMBOL; \
  56. break; \
  57. case R_ARM_RELATIVE: \
  58. *REL += (unsigned long) LOAD; \
  59. break; \
  60. case R_ARM_NONE: \
  61. break; \
  62. default: \
  63. SEND_STDERR("Aiieeee!"); \
  64. _dl_exit(1); \
  65. }
  66. /*
  67. * Transfer control to the user's application, once the dynamic loader
  68. * is done. This routine has to exit the current function, then
  69. * call the _dl_elf_main function.
  70. */
  71. #define START() return _dl_elf_main;
  72. /* Here we define the magic numbers that this dynamic loader should accept */
  73. #define MAGIC1 EM_ARM
  74. #undef MAGIC2
  75. /* Used for error messages */
  76. #define ELF_TARGET "ARM"
  77. struct elf_resolve;
  78. unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  79. #define do_rem(result, n, base) result = (n % base)
  80. /* 4096 bytes alignment */
  81. #define PAGE_ALIGN 0xfffff000
  82. #define ADDR_ALIGN 0xfff
  83. #define OFFS_ALIGN 0x7ffff000