dl-startup.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. " .text\n" \
  6. " .globl _dl_boot\n" \
  7. "_dl_boot:\n" \
  8. " mov r15, r4\n" \
  9. " mov.l .L_dl_boot2, 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_boot2:\n" \
  16. " .long _dl_boot2-.jmp_loc\n" \
  17. " .previous\n" \
  18. );
  19. #define DL_BOOT(X) static void __attribute__ ((unused)) _dl_boot2 (X)
  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;