dl-startup.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Any assembly language/system dependent hacks needed to setup boot1.c so it
  2. * will work as expected and cope with whatever platform specific wierdness is
  3. * needed for this architecture. */
  4. __asm__(
  5. " .text\n"
  6. " .globl _start\n"
  7. " .type _start,@function\n"
  8. " .hidden _start\n"
  9. "_start:\n"
  10. " mov r15, r4\n"
  11. " mov.l .L_dl_start, r0\n"
  12. " bsrf r0\n"
  13. " add #4, r4\n"
  14. ".jmp_loc:\n"
  15. " mov r0, r8 ! Save the user entry point address in r8\n"
  16. " mov.l .L_got, r12 ! Load the GOT on r12\n"
  17. " mova .L_got, r0\n"
  18. " add r0, r12\n"
  19. " mov.l .L_dl_skip_args,r0\n"
  20. " mov.l @(r0,r12),r0\n"
  21. " mov.l @r0,r0\n"
  22. " mov.l @r15,r5 ! Get the original argument count\n"
  23. " sub r0,r5 ! Subtract _dl_skip_args from it\n"
  24. " shll2 r0\n"
  25. " add r0,r15 ! Adjust the stack pointer to skip _dl_skip_args words\n"
  26. " mov.l r5,@r15 ! Store back the modified argument count\n"
  27. " mov.l .L_dl_fini, r0\n"
  28. " mov.l @(r0,r12), r4 ! Pass the finalizer in r4\n"
  29. " jmp @r8\n"
  30. " nop\n"
  31. ".L_dl_start:\n"
  32. " .long _dl_start-.jmp_loc\n"
  33. ".L_dl_skip_args:\n"
  34. " .long _dl_skip_args@GOT\n"
  35. ".L_dl_fini:\n"
  36. " .long _dl_fini@GOT\n"
  37. ".L_got:\n"
  38. " .long _GLOBAL_OFFSET_TABLE_\n"
  39. " .size _start,.-_start\n"
  40. " .previous\n"
  41. );
  42. /*
  43. * Get a pointer to the argv array. On many platforms this can be just
  44. * the address of the first argument, on other platforms we need to
  45. * do something a little more subtle here.
  46. */
  47. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS)
  48. /* We can't call functions earlier in the dl startup process */
  49. #define NO_FUNCS_BEFORE_BOOTSTRAP
  50. /*
  51. * Here is a macro to perform a relocation. This is only used when
  52. * bootstrapping the dynamic loader. RELP is the relocation that we
  53. * are performing, REL is the pointer to the address we are relocating.
  54. * SYMBOL is the symbol involved in the relocation, and LOAD is the
  55. * load address.
  56. */
  57. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
  58. switch(ELF_R_TYPE((RELP)->r_info)){ \
  59. case R_SH_REL32: \
  60. *(REL) = (SYMBOL) + (RELP)->r_addend \
  61. - (unsigned long)(REL); \
  62. break; \
  63. case R_SH_DIR32: \
  64. case R_SH_GLOB_DAT: \
  65. case R_SH_JMP_SLOT: \
  66. *(REL) = (SYMBOL) + (RELP)->r_addend; \
  67. break; \
  68. case R_SH_RELATIVE: \
  69. *(REL) = (LOAD) + (RELP)->r_addend; \
  70. break; \
  71. case R_SH_NONE: \
  72. break; \
  73. default: \
  74. _dl_exit(1); \
  75. }