crt0_x86_64_efi.S 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * crt0-efi-x86_64.S - x86_64 EFI startup code.
  4. * Copyright (C) 1999 Hewlett-Packard Co.
  5. * Contributed by David Mosberger <davidm@hpl.hp.com>.
  6. * Copyright (C) 2005 Intel Corporation
  7. * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
  8. *
  9. * All rights reserved.
  10. */
  11. .text
  12. .align 4
  13. .globl _start
  14. _start:
  15. subq $8, %rsp
  16. pushq %rcx
  17. pushq %rdx
  18. mov %rcx, %r8
  19. mov %rdx, %r9
  20. lea image_base(%rip), %rcx
  21. lea _DYNAMIC(%rip), %rdx
  22. call _relocate
  23. popq %rdx
  24. popq %rcx
  25. testq %rax, %rax
  26. jnz .exit
  27. call efi_main
  28. .exit:
  29. addq $8, %rsp
  30. ret
  31. /*
  32. * hand-craft a dummy .reloc section so EFI knows it's a relocatable
  33. * executable:
  34. */
  35. .data
  36. dummy: .long 0
  37. #define IMAGE_REL_ABSOLUTE 0
  38. .section .reloc, "a"
  39. label1:
  40. .long dummy-label1 /* Page RVA */
  41. .long 10 /* Block Size (2*4+2) */
  42. .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */