| 1 |
/* |
| 2 |
* crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications |
| 3 |
* |
| 4 |
* Copright (C) 2014 Linaro Ltd. <[email protected]> |
| 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 |
|
| 20 |
.text |
| 21 |
.align 12 |
| 22 |
|
| 23 |
.globl _start |
| 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 efi_main |
| 39 |
|
| 40 |
0: ldp x29, x30, [sp], #32 |
| 41 |
ret |
| 42 |
|
| 43 |
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable: |
| 44 |
.data |
| 45 |
.dummy0: |
| 46 |
.dummy1: |
| 47 |
.4byte 0 |
| 48 |
|
| 49 |
#define IMAGE_REL_ABSOLUTE 0 |
| 50 |
.section .reloc, "a" |
| 51 |
.4byte .dummy1-.dummy0 // Page RVA |
| 52 |
.4byte 10 // Block Size (2*4+2) |
| 53 |
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy |
| 54 |
.section .note.GNU-stack,"a" |