dl-startup.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Architecture specific code used by dl-startup.c
  3. */
  4. /* This code fixes the stack pointer so that the dynamic linker
  5. * can find argc, argv and auxvt (Auxillary Vector Table). */
  6. asm("" \
  7. " .text\n" \
  8. " .globl _dl_boot\n" \
  9. " .type _dl_boot,@function\n" \
  10. "_dl_boot:\n" \
  11. " move.d $sp,$r10\n" \
  12. " move.d $pc,$r9\n" \
  13. " add.d _dl_boot2 - ., $r9\n" \
  14. " jsr $r9\n" \
  15. );
  16. #define DL_BOOT(X) static void __attribute_used__ _dl_boot2 (X)
  17. /* Get a pointer to the argv array. On many platforms this can be just
  18. * the address if the first argument, on other platforms we need to
  19. * do something a little more subtle here. */
  20. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *) ARGS)
  21. /* Handle relocation of the symbols in the dynamic loader. */
  22. static inline
  23. void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
  24. unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
  25. {
  26. switch (ELF32_R_TYPE(rpnt->r_info)) {
  27. case R_CRIS_GLOB_DAT:
  28. case R_CRIS_JUMP_SLOT:
  29. case R_CRIS_32:
  30. *reloc_addr = symbol_addr;
  31. break;
  32. case R_CRIS_16_PCREL:
  33. *(short *) *reloc_addr = symbol_addr + rpnt->r_addend - *reloc_addr - 2;
  34. break;
  35. case R_CRIS_32_PCREL:
  36. *reloc_addr = symbol_addr + rpnt->r_addend - *reloc_addr - 4;
  37. break;
  38. case R_CRIS_NONE:
  39. break;
  40. case R_CRIS_RELATIVE:
  41. *reloc_addr = load_addr + rpnt->r_addend;
  42. break;
  43. default:
  44. _dl_exit(1);
  45. break;
  46. }
  47. }
  48. /* Transfer control to the user's application, once the dynamic loader is
  49. * done. This routine has to exit the current function, then call the
  50. * _dl_elf_main function. */
  51. #define START() __asm__ volatile ("moveq 0,$r8\n\t" \
  52. "move $r8,$srp\n\t" \
  53. "move.d %1,$sp\n\t" \
  54. "jump %0\n\t" \
  55. : : "r" (_dl_elf_main), "r" (args))