crt0_ia32_efi.S 1.0 KB

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