Path: blob/master/arch/arm/boot/compressed/efi-header.S
29269 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2013-2017 Linaro Ltd3* Authors: Roy Franz <[email protected]>4* Ard Biesheuvel <[email protected]>5*/67#include <linux/pe.h>8#include <linux/sizes.h>910.macro __nop11AR_CLASS( mov r0, r0 )12M_CLASS( nop.w )13.endm1415.macro __initial_nops16#ifdef CONFIG_EFI_STUB17@ This is a two-instruction NOP, which happens to bear the18@ PE/COFF signature "MZ" in the first two bytes, so the kernel19@ is accepted as an EFI binary. Booting via the UEFI stub20@ will not execute those instructions, but the ARM/Linux21@ boot protocol does, so we need some NOPs here.22.inst IMAGE_DOS_SIGNATURE | (0xe225 << 16) @ eor r5, r5, 0x4d00023eor r5, r5, 0x4d000 @ undo previous insn24#else25__nop26__nop27#endif28.endm2930.macro __EFI_HEADER31#ifdef CONFIG_EFI_STUB32.set start_offset, __efi_start - start33.org start + 0x3c34@35@ The PE header can be anywhere in the file, but for36@ simplicity we keep it together with the MSDOS header37@ The offset to the PE/COFF header needs to be at offset38@ 0x3C in the MSDOS header.39@ The only 2 fields of the MSDOS header that are used are this40@ PE/COFF offset, and the "MZ" bytes at offset 0x0.41@42.long pe_header - start @ Offset to the PE header.4344pe_header:45.long IMAGE_NT_SIGNATURE4647coff_header:48.short IMAGE_FILE_MACHINE_THUMB @ Machine49.short section_count @ NumberOfSections50.long 0 @ TimeDateStamp51.long 0 @ PointerToSymbolTable52.long 0 @ NumberOfSymbols53.short section_table - optional_header @ SizeOfOptionalHeader54.short IMAGE_FILE_32BIT_MACHINE | \55IMAGE_FILE_DEBUG_STRIPPED | \56IMAGE_FILE_EXECUTABLE_IMAGE | \57IMAGE_FILE_LINE_NUMS_STRIPPED @ Characteristics5859#define __pecoff_code_size (__pecoff_data_start - __efi_start)6061optional_header:62.short IMAGE_NT_OPTIONAL_HDR32_MAGIC @ PE32 format63.byte 0x02 @ MajorLinkerVersion64.byte 0x14 @ MinorLinkerVersion65.long __pecoff_code_size @ SizeOfCode66.long __pecoff_data_size @ SizeOfInitializedData67.long 0 @ SizeOfUninitializedData68.long efi_pe_entry - start @ AddressOfEntryPoint69.long start_offset @ BaseOfCode70.long __pecoff_data_start - start @ BaseOfData7172extra_header_fields:73.long 0 @ ImageBase74.long SZ_4K @ SectionAlignment75.long SZ_512 @ FileAlignment76.short 0 @ MajorOsVersion77.short 0 @ MinorOsVersion78.short LINUX_EFISTUB_MAJOR_VERSION @ MajorImageVersion79.short LINUX_EFISTUB_MINOR_VERSION @ MinorImageVersion80.short 0 @ MajorSubsystemVersion81.short 0 @ MinorSubsystemVersion82.long 0 @ Win32VersionValue8384.long __pecoff_end - start @ SizeOfImage85.long start_offset @ SizeOfHeaders86.long 0 @ CheckSum87.short IMAGE_SUBSYSTEM_EFI_APPLICATION @ Subsystem88.short 0 @ DllCharacteristics89.long 0 @ SizeOfStackReserve90.long 0 @ SizeOfStackCommit91.long 0 @ SizeOfHeapReserve92.long 0 @ SizeOfHeapCommit93.long 0 @ LoaderFlags94.long (section_table - .) / 8 @ NumberOfRvaAndSizes9596.quad 0 @ ExportTable97.quad 0 @ ImportTable98.quad 0 @ ResourceTable99.quad 0 @ ExceptionTable100.quad 0 @ CertificationTable101.quad 0 @ BaseRelocationTable102103section_table:104.ascii ".text\0\0\0"105.long __pecoff_code_size @ VirtualSize106.long __efi_start @ VirtualAddress107.long __pecoff_code_size @ SizeOfRawData108.long __efi_start @ PointerToRawData109.long 0 @ PointerToRelocations110.long 0 @ PointerToLineNumbers111.short 0 @ NumberOfRelocations112.short 0 @ NumberOfLineNumbers113.long IMAGE_SCN_CNT_CODE | \114IMAGE_SCN_MEM_READ | \115IMAGE_SCN_MEM_EXECUTE @ Characteristics116117.ascii ".data\0\0\0"118.long __pecoff_data_size @ VirtualSize119.long __pecoff_data_start - start @ VirtualAddress120.long __pecoff_data_rawsize @ SizeOfRawData121.long __pecoff_data_start - start @ PointerToRawData122.long 0 @ PointerToRelocations123.long 0 @ PointerToLineNumbers124.short 0 @ NumberOfRelocations125.short 0 @ NumberOfLineNumbers126.long IMAGE_SCN_CNT_INITIALIZED_DATA | \127IMAGE_SCN_MEM_READ | \128IMAGE_SCN_MEM_WRITE @ Characteristics129130.set section_count, (. - section_table) / 40131132.align 12133__efi_start:134#endif135.endm136137138