dl-startup.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Architecture specific code used by dl-startup.c
  4. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  5. */
  6. asm(
  7. " .text\n"
  8. " .globl _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. /* Get a pointer to the argv array. On many platforms this can be just
  16. * the address if the first argument, on other platforms we need to
  17. * do something a little more subtle here. */
  18. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
  19. /* Handle relocation of the symbols in the dynamic loader. */
  20. static inline
  21. void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
  22. unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
  23. {
  24. switch (ELF32_R_TYPE(rpnt->r_info))
  25. {
  26. case R_386_32:
  27. *reloc_addr += symbol_addr;
  28. break;
  29. case R_386_PC32:
  30. *reloc_addr += symbol_addr - (unsigned long) reloc_addr;
  31. break;
  32. case R_386_GLOB_DAT:
  33. case R_386_JMP_SLOT:
  34. *reloc_addr = symbol_addr;
  35. break;
  36. case R_386_RELATIVE:
  37. *reloc_addr += load_addr;
  38. break;
  39. default:
  40. _dl_exit(1);
  41. }
  42. }
  43. /* Transfer control to the user's application, once the dynamic loader is
  44. * done. This routine has to exit the current function, then call the
  45. * _dl_elf_main function. */
  46. #define START() { \
  47. int status = 0; \
  48. __asm__ volatile ("leave\n\t" \
  49. "jmp *%%eax\n\t" \
  50. : "=a" (status) : "a" (_dl_elf_main)); \
  51. }