crt0_x86_64_efi.S 890 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * crt0-efi-x86_64.S - x86_64 EFI startup code.
  3. * Copyright (C) 1999 Hewlett-Packard Co.
  4. * Contributed by David Mosberger <davidm@hpl.hp.com>.
  5. * Copyright (C) 2005 Intel Co.
  6. * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
  7. *
  8. * All rights reserved.
  9. * SPDX-License-Identifier: BSD-3-Clause
  10. */
  11. .text
  12. .align 4
  13. .globl _start
  14. _start:
  15. subq $8, %rsp
  16. pushq %rcx
  17. pushq %rdx
  18. 0:
  19. lea image_base(%rip), %rdi
  20. lea _DYNAMIC(%rip), %rsi
  21. popq %rcx
  22. popq %rdx
  23. pushq %rcx
  24. pushq %rdx
  25. call _relocate
  26. popq %rdi
  27. popq %rsi
  28. call efi_main
  29. addq $8, %rsp
  30. .exit:
  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, "a"
  40. label1:
  41. .long dummy-label1 /* Page RVA */
  42. .long 10 /* Block Size (2*4+2) */
  43. .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */