1530d68baSNigel Croxon/* crt0-efi-x86_64.S - x86_64 EFI startup code. 2530d68baSNigel Croxon Copyright (C) 1999 Hewlett-Packard Co. 3530d68baSNigel Croxon Contributed by David Mosberger <davidm@hpl.hp.com>. 4530d68baSNigel Croxon Copyright (C) 2005 Intel Co. 5530d68baSNigel Croxon Contributed by Fenghua Yu <fenghua.yu@intel.com>. 6530d68baSNigel Croxon 7530d68baSNigel Croxon All rights reserved. 8530d68baSNigel Croxon 9530d68baSNigel Croxon Redistribution and use in source and binary forms, with or without 10530d68baSNigel Croxon modification, are permitted provided that the following conditions 11530d68baSNigel Croxon are met: 12530d68baSNigel Croxon 13530d68baSNigel Croxon * Redistributions of source code must retain the above copyright 14530d68baSNigel Croxon notice, this list of conditions and the following disclaimer. 15530d68baSNigel Croxon * Redistributions in binary form must reproduce the above 16530d68baSNigel Croxon copyright notice, this list of conditions and the following 17530d68baSNigel Croxon disclaimer in the documentation and/or other materials 18530d68baSNigel Croxon provided with the distribution. 19530d68baSNigel Croxon * Neither the name of Hewlett-Packard Co. nor the names of its 20530d68baSNigel Croxon contributors may be used to endorse or promote products derived 21530d68baSNigel Croxon from this software without specific prior written permission. 22530d68baSNigel Croxon 23530d68baSNigel Croxon THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 24530d68baSNigel Croxon CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 25530d68baSNigel Croxon INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26530d68baSNigel Croxon MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27530d68baSNigel Croxon DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 28530d68baSNigel Croxon BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 29530d68baSNigel Croxon OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30530d68baSNigel Croxon PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31530d68baSNigel Croxon PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32530d68baSNigel Croxon THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 33530d68baSNigel Croxon TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34530d68baSNigel Croxon THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35530d68baSNigel Croxon SUCH DAMAGE. 36530d68baSNigel Croxon*/ 37530d68baSNigel Croxon .text 38530d68baSNigel Croxon .align 4 39530d68baSNigel Croxon 40530d68baSNigel Croxon .globl _start 41*64027ee9SCallum Farmer .type _start,%function 42530d68baSNigel Croxon_start: 43530d68baSNigel Croxon subq $8, %rsp 44530d68baSNigel Croxon pushq %rcx 45530d68baSNigel Croxon pushq %rdx 46530d68baSNigel Croxon 47530d68baSNigel Croxon0: 48530d68baSNigel Croxon lea ImageBase(%rip), %rdi 49530d68baSNigel Croxon lea _DYNAMIC(%rip), %rsi 50530d68baSNigel Croxon 51530d68baSNigel Croxon popq %rcx 52530d68baSNigel Croxon popq %rdx 53530d68baSNigel Croxon pushq %rcx 54530d68baSNigel Croxon pushq %rdx 55530d68baSNigel Croxon call _relocate 56530d68baSNigel Croxon 57530d68baSNigel Croxon popq %rdi 58530d68baSNigel Croxon popq %rsi 59530d68baSNigel Croxon 604f8b339fSPeter Jones call _entry 61530d68baSNigel Croxon addq $8, %rsp 62530d68baSNigel Croxon 63530d68baSNigel Croxon.exit: 64530d68baSNigel Croxon ret 65530d68baSNigel Croxon 66530d68baSNigel Croxon // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable: 67530d68baSNigel Croxon 68530d68baSNigel Croxon .data 699e6cb215SCallum Farmerdummy: .4byte 0 70530d68baSNigel Croxon 71530d68baSNigel Croxon#define IMAGE_REL_ABSOLUTE 0 72530d68baSNigel Croxon .section .reloc, "a" 73530d68baSNigel Croxonlabel1: 749e6cb215SCallum Farmer .4byte dummy-label1 // Page RVA 759e6cb215SCallum Farmer .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits 769e6cb215SCallum Farmer .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy 779e6cb215SCallum Farmer .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy 78530d68baSNigel Croxon 79803b49c4SSergei Trofimovich#if defined(__ELF__) && defined(__linux__) 80803b49c4SSergei Trofimovich .section .note.GNU-stack,"",%progbits 81803b49c4SSergei Trofimovich#endif 82