Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 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 Co. |
| 7 | * Contributed by Fenghua Yu <fenghua.yu@intel.com>. |
| 8 | * |
| 9 | * All rights reserved. |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 10 | */ |
| 11 | .text |
| 12 | .align 4 |
| 13 | |
| 14 | .globl _start |
| 15 | _start: |
| 16 | subq $8, %rsp |
| 17 | pushq %rcx |
| 18 | pushq %rdx |
| 19 | |
| 20 | 0: |
| 21 | lea image_base(%rip), %rdi |
| 22 | lea _DYNAMIC(%rip), %rsi |
| 23 | |
| 24 | popq %rcx |
| 25 | popq %rdx |
| 26 | pushq %rcx |
| 27 | pushq %rdx |
| 28 | call _relocate |
| 29 | |
| 30 | popq %rdi |
| 31 | popq %rsi |
| 32 | |
| 33 | call efi_main |
| 34 | addq $8, %rsp |
| 35 | |
| 36 | .exit: |
| 37 | ret |
| 38 | |
| 39 | /* |
| 40 | * hand-craft a dummy .reloc section so EFI knows it's a relocatable |
| 41 | * executable: |
| 42 | */ |
| 43 | .data |
| 44 | dummy: .long 0 |
| 45 | |
| 46 | #define IMAGE_REL_ABSOLUTE 0 |
| 47 | .section .reloc, "a" |
| 48 | label1: |
| 49 | .long dummy-label1 /* Page RVA */ |
| 50 | .long 10 /* Block Size (2*4+2) */ |
| 51 | .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */ |