crt0_ia32_efi.S 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * crt0-efi-ia32.S - x86 EFI startup code.
  3. *
  4. * Copyright (C) 1999 Hewlett-Packard Co.
  5. * Contributed by David Mosberger <davidm@hpl.hp.com>.
  6. * All rights reserved.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. .text
  11. .align 4
  12. .globl _start
  13. _start:
  14. pushl %ebp
  15. movl %esp,%ebp
  16. pushl 12(%ebp) # copy "image" argument
  17. pushl 8(%ebp) # copy "systab" argument
  18. call 0f
  19. 0: popl %eax
  20. movl %eax,%ebx
  21. addl $image_base-0b,%eax # %eax = ldbase
  22. addl $_DYNAMIC-0b,%ebx # %ebx = _DYNAMIC
  23. pushl %ebx # pass _DYNAMIC as second argument
  24. pushl %eax # pass ldbase as first argument
  25. call _relocate
  26. popl %ebx
  27. popl %ebx
  28. testl %eax,%eax
  29. jne .exit
  30. call efi_main # call app with "image" and "systab" argument
  31. .exit: leave
  32. ret
  33. /*
  34. * hand-craft a dummy .reloc section so EFI knows it's a relocatable
  35. * executable:
  36. */
  37. .data
  38. dummy: .long 0
  39. #define IMAGE_REL_ABSOLUTE 0
  40. .section .reloc
  41. .long dummy /* Page RVA */
  42. .long 10 /* Block Size (2*4+2) */
  43. .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */