dl-startup.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. See arm/boot1_arch.h for an example of what
  4. * can be done.
  5. */
  6. asm(
  7. " .text\n"
  8. " .global _start\n"
  9. " .type _start,%function\n"
  10. "_start:\n"
  11. " .set _start,_dl_start\n"
  12. " .size _start,.-_start\n"
  13. " .previous\n"
  14. );
  15. /*
  16. * Get a pointer to the argv array. On many platforms this can be just
  17. * the address if the first argument, on other platforms we need to
  18. * do something a little more subtle here. We assume that argc is stored
  19. * at the word just below the argvp that we return here.
  20. */
  21. #define GET_ARGV(ARGVP, ARGS) __asm__("\tadd %%fp,68,%0\n" : "=r" (ARGVP));
  22. /*
  23. * Here is a macro to perform a relocation. This is only used when
  24. * bootstrapping the dynamic loader.
  25. */
  26. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
  27. switch(ELF32_R_TYPE((RELP)->r_info)) { \
  28. case R_SPARC_32: \
  29. *REL = SYMBOL + (RELP)->r_addend; \
  30. break; \
  31. case R_SPARC_GLOB_DAT: \
  32. *REL = SYMBOL + (RELP)->r_addend; \
  33. break; \
  34. case R_SPARC_JMP_SLOT: \
  35. REL[1] = 0x03000000 | ((SYMBOL >> 10) & 0x3fffff); \
  36. REL[2] = 0x81c06000 | (SYMBOL & 0x3ff); \
  37. break; \
  38. case R_SPARC_NONE: \
  39. break; \
  40. case R_SPARC_WDISP30: \
  41. break; \
  42. case R_SPARC_RELATIVE: \
  43. *REL += (unsigned int) LOAD + (RELP)->r_addend; \
  44. break; \
  45. default: \
  46. _dl_exit(1); \
  47. }
  48. /*
  49. * Transfer control to the user's application, once the dynamic loader
  50. * is done. The crt calls atexit with $g1 if not null, so we need to
  51. * ensure that it contains NULL.
  52. */
  53. #define START() \
  54. __asm__ volatile ( \
  55. "add %%g0,%%g0,%%g1\n\t" \
  56. "jmpl %0, %%o7\n\t" \
  57. "restore %%g0,%%g0,%%g0\n\t" \
  58. : /*"=r" (status) */ : \
  59. "r" (_dl_elf_main): "g1", "o0", "o1")