crt0-efi-x86_64.S revision 1.1 1 /* $NetBSD: crt0-efi-x86_64.S,v 1.1 2014/04/01 16:16:08 jakllsch Exp $ */
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 (at) hpl.hp.com>.
6 Copyright (C) 2005 Intel Co.
7 Contributed by Fenghua Yu <fenghua.yu (at) intel.com>.
8
9 All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the following
19 disclaimer in the documentation and/or other materials
20 provided with the distribution.
21 * Neither the name of Hewlett-Packard Co. nor the names of its
22 contributors may be used to endorse or promote products derived
23 from this software without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
26 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
27 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
30 BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
31 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
36 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 SUCH DAMAGE.
38 */
39 .text
40 .align 4
41
42 .globl _start
43 _start:
44 subq $8, %rsp
45 pushq %rcx
46 pushq %rdx
47
48 0:
49 lea ImageBase(%rip), %rdi
50 lea _DYNAMIC(%rip), %rsi
51
52 popq %rcx
53 popq %rdx
54 pushq %rcx
55 pushq %rdx
56 call _relocate
57
58 popq %rdi
59 popq %rsi
60
61 call efi_main
62 addq $8, %rsp
63
64 .exit:
65 ret
66
67 // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
68
69 .data
70 dummy: .long 0
71
72 #define IMAGE_REL_ABSOLUTE 0
73 .section .reloc, "a"
74 label1:
75 .long dummy-label1 // Page RVA
76 .long 10 // Block Size (2*4+2)
77 .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
78
79