xref: /DragonStub/gnuefi/crt0-efi-aarch64.S (revision 6f333cfc914e7cfacc4d3ef3e034e4483f0ba8b2)
1/*
2 * crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications
3 *
4 * Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice and this list of conditions, without modification.
11 * 2. The name of the author may not be used to endorse or promote products
12 *    derived from this software without specific prior written permission.
13 *
14 * Alternatively, this software may be distributed under the terms of the
15 * GNU General Public License as published by the Free Software Foundation;
16 * either version 2 of the License, or (at your option) any later version.
17 */
18
19	.text
20	.align		12
21
22	.globl _start
23	.type _start,%function
24_start:
25	stp		x29, x30, [sp, #-32]!
26	mov		x29, sp
27
28	stp		x0, x1, [sp, #16]
29	mov		x2, x0
30	mov		x3, x1
31	adr		x0, ImageBase
32	adrp		x1, _DYNAMIC
33	add		x1, x1, #:lo12:_DYNAMIC
34	bl		_relocate
35	cbnz		x0, 0f
36
37	ldp		x0, x1, [sp, #16]
38	bl		_entry
39
400:	ldp		x29, x30, [sp], #32
41	ret
42
43	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
44
45 	.data
46dummy:	.4byte	0
47
48#define IMAGE_REL_ABSOLUTE	0
49 	.section .reloc, "a"
50label1:
51	.4byte	dummy-label1				// Page RVA
52	.4byte	12					// Block Size (2*4+2*2), must be aligned by 32 Bits
53	.2byte	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
54	.2byte	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
55
56#if defined(__ELF__) && defined(__linux__)
57	.section .note.GNU-stack,"",%progbits
58#endif
59