crt0_x86_64_efi.S 883 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. lea image_base(%rip), %rcx
  19. lea _DYNAMIC(%rip), %rdx
  20. call _relocate
  21. popq %rdx
  22. popq %rcx
  23. testq %rax, %rax
  24. jnz .exit
  25. call efi_main
  26. .exit:
  27. addq $8, %rsp
  28. ret
  29. /*
  30. * hand-craft a dummy .reloc section so EFI knows it's a relocatable
  31. * executable:
  32. */
  33. .data
  34. dummy: .long 0
  35. #define IMAGE_REL_ABSOLUTE 0
  36. .section .reloc, "a"
  37. label1:
  38. .long dummy-label1 /* Page RVA */
  39. .long 10 /* Block Size (2*4+2) */
  40. .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */