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_start: 24 stp x29, x30, [sp, #-32]! 25 mov x29, sp 26 27 stp x0, x1, [sp, #16] 28 mov x2, x0 29 mov x3, x1 30 adr x0, ImageBase 31 adrp x1, _DYNAMIC 32 add x1, x1, #:lo12:_DYNAMIC 33 bl _relocate 34 cbnz x0, 0f 35 36 ldp x0, x1, [sp, #16] 37 bl _entry 38 390: ldp x29, x30, [sp], #32 40 ret 41 42 // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable: 43 44 .data 45dummy: .long 0 46 47#define IMAGE_REL_ABSOLUTE 0 48 .section .reloc, "a" 49label1: 50 .long dummy-label1 // Page RVA 51 .long 12 // Block Size (2*4+2*2), must be aligned by 32 Bits 52 .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy 53 .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy 54 55#if defined(__ELF__) && defined(__linux__) 56 .section .note.GNU-stack,"",%progbits 57#endif 58