dl-startup.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. "_start:\n"
  9. " mov r15, r4\n"
  10. " mov.l .L_dl_start, r0\n"
  11. " bsrf r0\n"
  12. " add #4, r4\n"
  13. ".jmp_loc:\n"
  14. " mov r0, r8 ! Save the user entry point address in r8\n"
  15. " mov.l .L_got, r12 ! Load the GOT on r12\n"
  16. " mova .L_got, r0\n"
  17. " add r0, r12\n"
  18. " mov.l .L_dl_fini, r0\n"
  19. " mov.l @(r0,r12), r4 ! Pass the finalizer in r4\n"
  20. " jmp @r8\n"
  21. " nop\n"
  22. ".L_dl_start:\n"
  23. " .long _dl_start-.jmp_loc\n"
  24. ".L_dl_fini:\n"
  25. " .long _dl_fini@GOT\n"
  26. ".L_got:\n"
  27. " .long _GLOBAL_OFFSET_TABLE_\n"
  28. " .size _start,.-_start\n"
  29. " .previous\n"
  30. );
  31. /*
  32. * Get a pointer to the argv array. On many platforms this can be just
  33. * the address of the first argument, on other platforms we need to
  34. * do something a little more subtle here.
  35. */
  36. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS)
  37. /* We can't call functions earlier in the dl startup process */
  38. #define NO_FUNCS_BEFORE_BOOTSTRAP
  39. /*
  40. * Here is a macro to perform a relocation. This is only used when
  41. * bootstrapping the dynamic loader. RELP is the relocation that we
  42. * are performing, REL is the pointer to the address we are relocating.
  43. * SYMBOL is the symbol involved in the relocation, and LOAD is the
  44. * load address.
  45. */
  46. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
  47. switch(ELF32_R_TYPE((RELP)->r_info)){ \
  48. case R_SH_REL32: \
  49. *(REL) = (SYMBOL) + (RELP)->r_addend \
  50. - (unsigned long)(REL); \
  51. break; \
  52. case R_SH_DIR32: \
  53. case R_SH_GLOB_DAT: \
  54. case R_SH_JMP_SLOT: \
  55. *(REL) = (SYMBOL) + (RELP)->r_addend; \
  56. break; \
  57. case R_SH_RELATIVE: \
  58. *(REL) = (LOAD) + (RELP)->r_addend; \
  59. break; \
  60. case R_SH_NONE: \
  61. break; \
  62. default: \
  63. _dl_exit(1); \
  64. }