dl-startup.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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@codpoet.org>
  5. */
  6. /* For x86 we do not need any special setup so go right to _dl_boot() */
  7. #define DL_BOOT(X) __attribute__ ((unused)) void _dl_boot (X)
  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. */
  11. #define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
  12. /* Handle relocation of the symbols in the dynamic loader. */
  13. static inline
  14. void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
  15. unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
  16. {
  17. switch (ELF32_R_TYPE(rpnt->r_info))
  18. {
  19. case R_386_32:
  20. *reloc_addr += symbol_addr;
  21. break;
  22. case R_386_PC32:
  23. *reloc_addr += symbol_addr - (unsigned long) reloc_addr;
  24. break;
  25. case R_386_GLOB_DAT:
  26. case R_386_JMP_SLOT:
  27. *reloc_addr = symbol_addr;
  28. break;
  29. case R_386_RELATIVE:
  30. *reloc_addr += load_addr;
  31. break;
  32. default:
  33. _dl_exit(1);
  34. }
  35. }
  36. /* Transfer control to the user's application, once the dynamic loader is
  37. * done. This routine has to exit the current function, then call the
  38. * _dl_elf_main function. */
  39. #define START() \
  40. __asm__ volatile ("leave\n\t" \
  41. "jmp *%%eax\n\t" \
  42. : "=a" (status) : "a" (_dl_elf_main))