dl-startup.h 1.9 KB

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