sysdep.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Various assmbly language/system dependent hacks that are required
  2. so that we can minimize the amount of platform specific code. */
  3. /* Define this if the system uses RELOCA. */
  4. #define ELF_USES_RELOCA
  5. /* Get a pointer to the argv array. On many platforms this can be
  6. just the address if the first argument, on other platforms we need
  7. to do something a little more subtle here. */
  8. #define GET_ARGV(ARGVP, ARGS) ((ARGVP) = ((unsigned int *) &(ARGS)))
  9. /* Get the address of the Global offset table. This must be absolute,
  10. not relative. */
  11. #define GET_GOT(X) __asm__ ("movel %%a5,%0" : "=g" (X))
  12. /* Initialization sequence for a GOT. */
  13. #define INIT_GOT(GOT_BASE,MODULE) \
  14. { \
  15. GOT_BASE[2] = (int) _dl_linux_resolve; \
  16. GOT_BASE[1] = (int) (MODULE); \
  17. }
  18. /* Here is a macro to perform a relocation. This is only used when
  19. bootstrapping the dynamic loader. RELP is the relocation that we
  20. are performing, REL is the pointer to the address we are
  21. relocating. SYMBOL is the symbol involved in the relocation, and
  22. LOAD is the load address. */
  23. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD) \
  24. switch (ELF32_R_TYPE ((RELP)->r_info)) \
  25. { \
  26. case R_68K_8: \
  27. *(char *) (REL) = (SYMBOL) + (RELP)->r_addend; \
  28. break; \
  29. case R_68K_16: \
  30. *(short *) (REL) = (SYMBOL) + (RELP)->r_addend; \
  31. break; \
  32. case R_68K_32: \
  33. *(REL) = (SYMBOL) + (RELP)->r_addend; \
  34. break; \
  35. case R_68K_PC8: \
  36. *(char *) (REL) = ((SYMBOL) + (RELP)->r_addend \
  37. - (unsigned int) (REL)); \
  38. break; \
  39. case R_68K_PC16: \
  40. *(short *) (REL) = ((SYMBOL) + (RELP)->r_addend \
  41. - (unsigned int) (REL)); \
  42. break; \
  43. case R_68K_PC32: \
  44. *(REL) = ((SYMBOL) + (RELP)->r_addend \
  45. - (unsigned int) (REL)); \
  46. break; \
  47. case R_68K_GLOB_DAT: \
  48. case R_68K_JMP_SLOT: \
  49. *(REL) = (SYMBOL); \
  50. break; \
  51. case R_68K_RELATIVE: /* Compatibility kludge */ \
  52. *(REL) = ((unsigned int) (LOAD) + ((RELP)->r_addend ? : *(REL))); \
  53. break; \
  54. default: \
  55. _dl_exit (1); \
  56. }
  57. /* Transfer control to the user's application, once the dynamic loader
  58. is done. */
  59. #define START() \
  60. __asm__ volatile ("unlk %%a6\n\t" \
  61. "jmp %0@" \
  62. : : "a" (_dl_elf_main));
  63. /* Here we define the magic numbers that this dynamic loader should accept */
  64. #define MAGIC1 EM_68K
  65. #undef MAGIC2
  66. /* Used for error messages */
  67. #define ELF_TARGET "m68k"
  68. struct elf_resolve;
  69. extern unsigned int _dl_linux_resolver (int, int, struct elf_resolve *, int);
  70. /* Define this because we do not want to call .udiv in the library.
  71. Not needed for m68k. */
  72. #define do_rem(result, n, base) ((result) = (n) % (base))