dl-startup.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Any assmbly 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. " .globl _start\n"
  6. " .type _start,@function\n"
  7. "_start:\n"
  8. " mov r15, r4\n"
  9. " mov.l .L_dl_start, r0\n"
  10. " bsrf r0\n"
  11. " add #4, r4\n"
  12. ".jmp_loc:\n"
  13. " jmp @r0\n"
  14. " mov #0, r4 !call _start with arg == 0\n"
  15. ".L_dl_start:\n"
  16. " .long _dl_start-.jmp_loc\n"
  17. " .size _start,.-_start\n"
  18. " .previous\n"
  19. );
  20. /*
  21. * Get a pointer to the argv array. On many platforms this can be just
  22. * the address if the first argument, on other platforms we need to
  23. * do something a little more subtle here.
  24. */
  25. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS)
  26. /*
  27. * Here is a macro to perform a relocation. This is only used when
  28. * bootstrapping the dynamic loader. RELP is the relocation that we
  29. * are performing, REL is the pointer to the address we are relocating.
  30. * SYMBOL is the symbol involved in the relocation, and LOAD is the
  31. * load address.
  32. */
  33. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
  34. switch(ELF32_R_TYPE((RELP)->r_info)){ \
  35. case R_SH_REL32: \
  36. *(REL) = (SYMBOL) + (RELP)->r_addend \
  37. - (unsigned long)(REL); \
  38. break; \
  39. case R_SH_DIR32: \
  40. case R_SH_GLOB_DAT: \
  41. case R_SH_JMP_SLOT: \
  42. *(REL) = (SYMBOL) + (RELP)->r_addend; \
  43. break; \
  44. case R_SH_RELATIVE: \
  45. *(REL) = (LOAD) + (RELP)->r_addend; \
  46. break; \
  47. case R_SH_NONE: \
  48. break; \
  49. default: \
  50. SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc type "); \
  51. SEND_NUMBER_STDERR(ELF32_R_TYPE((RELP)->r_info), 1); \
  52. SEND_STDERR("REL, SYMBOL, LOAD: "); \
  53. SEND_ADDRESS_STDERR(REL, 0); \
  54. SEND_STDERR(", "); \
  55. SEND_ADDRESS_STDERR(SYMBOL, 0); \
  56. SEND_STDERR(", "); \
  57. SEND_ADDRESS_STDERR(LOAD, 1); \
  58. _dl_exit(1); \
  59. }
  60. /*
  61. * Transfer control to the user's application, once the dynamic loader
  62. * is done. This routine has to exit the current function, then
  63. * call the _dl_elf_main function.
  64. */
  65. #define START() return _dl_elf_main;