2017-03-23 19:00:46 +00:00
/ *
* Copyright ( C ) 2 0 1 3 - 2 0 1 7 L i n a r o , L t d .
* Copyright ( C ) 2 0 1 3 , 2 0 1 4 R e d H a t , I n c .
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
* /
2017-03-23 19:00:50 +00:00
# include < l i n u x / p e . h >
# include < l i n u x / s i z e s . h >
2017-03-23 19:00:46 +00:00
.macro __EFI_PE_HEADER
2017-03-23 19:00:50 +00:00
.long PE_MAGIC
2017-03-23 19:00:46 +00:00
coff_header :
2017-03-23 19:00:50 +00:00
.short IMAGE_FILE_MACHINE_ARM64 / / Machine
.short section_count / / NumberOfSections
2017-03-23 19:00:46 +00:00
.long 0 / / TimeDateStamp
.long 0 / / PointerToSymbolTable
2017-03-23 19:00:48 +00:00
.long 0 / / NumberOfSymbols
2017-03-23 19:00:46 +00:00
.short section_table - optional_ h e a d e r / / S i z e O f O p t i o n a l H e a d e r
2017-03-23 19:00:50 +00:00
.short IMAGE_FILE_DEBUG_STRIPPED | \
IMAGE_ F I L E _ E X E C U T A B L E _ I M A G E | \
IMAGE_ F I L E _ L I N E _ N U M S _ S T R I P P E D / / C h a r a c t e r i s t i c s
2017-03-23 19:00:46 +00:00
optional_header :
2017-03-23 19:00:50 +00:00
.short PE_OPT_MAGIC_PE32PLUS / / PE3 2 + f o r m a t
2017-03-23 19:00:46 +00:00
.byte 0x02 / / MajorLinkerVersion
.byte 0x14 / / MinorLinkerVersion
2017-03-23 19:00:51 +00:00
.long __initdata_begin - efi_ h e a d e r _ e n d / / S i z e O f C o d e
.long __pecoff_data_size / / SizeOfInitializedData
2017-03-23 19:00:46 +00:00
.long 0 / / SizeOfUninitializedData
.long __efistub_entry - _ head / / A d d r e s s O f E n t r y P o i n t
.long efi_header_end - _ head / / B a s e O f C o d e
extra_header_fields :
.quad 0 / / ImageBase
2017-03-23 19:00:50 +00:00
.long SZ_4K / / SectionAlignment
2017-03-23 19:00:46 +00:00
.long PECOFF_FILE_ALIGNMENT / / FileAlignment
.short 0 / / MajorOperatingSystemVersion
.short 0 / / MinorOperatingSystemVersion
.short 0 / / MajorImageVersion
.short 0 / / MinorImageVersion
.short 0 / / MajorSubsystemVersion
.short 0 / / MinorSubsystemVersion
.long 0 / / Win3 2 V e r s i o n V a l u e
.long _end - _ head / / S i z e O f I m a g e
/ / Everything b e f o r e t h e k e r n e l i m a g e i s c o n s i d e r e d p a r t o f t h e h e a d e r
.long efi_header_end - _ head / / S i z e O f H e a d e r s
.long 0 / / CheckSum
2017-03-23 19:00:50 +00:00
.short IMAGE_SUBSYSTEM_EFI_APPLICATION / / Subsystem
2017-03-23 19:00:46 +00:00
.short 0 / / DllCharacteristics
.quad 0 / / SizeOfStackReserve
.quad 0 / / SizeOfStackCommit
.quad 0 / / SizeOfHeapReserve
.quad 0 / / SizeOfHeapCommit
.long 0 / / LoaderFlags
.long ( section_ t a b l e - . ) / 8 / / N u m b e r O f R v a A n d S i z e s
.quad 0 / / ExportTable
.quad 0 / / ImportTable
.quad 0 / / ResourceTable
.quad 0 / / ExceptionTable
.quad 0 / / CertificationTable
.quad 0 / / BaseRelocationTable
# ifdef C O N F I G _ D E B U G _ E F I
.long efi_debug_table - _ head / / D e b u g T a b l e
.long efi_debug_table_size
# endif
/ / Section t a b l e
section_table :
2017-03-23 19:00:50 +00:00
.ascii " .text \ 0 \ 0 \ 0 "
2017-03-23 19:00:51 +00:00
.long __initdata_begin - efi_ h e a d e r _ e n d / / V i r t u a l S i z e
2017-03-23 19:00:46 +00:00
.long efi_header_end - _ head / / V i r t u a l A d d r e s s
2017-03-23 19:00:51 +00:00
.long __initdata_begin - efi_ h e a d e r _ e n d / / S i z e O f R a w D a t a
2017-03-23 19:00:46 +00:00
.long efi_header_end - _ head / / P o i n t e r T o R a w D a t a
.long 0 / / PointerToRelocations
.long 0 / / PointerToLineNumbers
.short 0 / / NumberOfRelocations
.short 0 / / NumberOfLineNumbers
2017-03-23 19:00:50 +00:00
.long IMAGE_SCN_CNT_CODE | \
2017-03-23 19:00:51 +00:00
IMAGE_ S C N _ M E M _ R E A D | \
IMAGE_ S C N _ M E M _ E X E C U T E / / C h a r a c t e r i s t i c s
.ascii " .data \ 0 \ 0 \ 0 "
.long __pecoff_data_size / / VirtualSize
.long __initdata_begin - _ head / / V i r t u a l A d d r e s s
.long __pecoff_data_rawsize / / SizeOfRawData
.long __initdata_begin - _ head / / P o i n t e r T o R a w D a t a
.long 0 / / PointerToRelocations
.long 0 / / PointerToLineNumbers
.short 0 / / NumberOfRelocations
.short 0 / / NumberOfLineNumbers
.long IMAGE_SCN_CNT_INITIALIZED_DATA | \
2017-03-23 19:00:50 +00:00
IMAGE_ S C N _ M E M _ R E A D | \
IMAGE_ S C N _ M E M _ W R I T E / / C h a r a c t e r i s t i c s
.set section_ c o u n t , ( . - s e c t i o n _ t a b l e ) / 4 0
2017-03-23 19:00:46 +00:00
# ifdef C O N F I G _ D E B U G _ E F I
/ *
* The d e b u g t a b l e i s r e f e r e n c e d v i a i t s R e l a t i v e V i r t u a l A d d r e s s ( R V A ) ,
* which i s o n l y d e f i n e d f o r t h o s e p a r t s o f t h e i m a g e t h a t a r e c o v e r e d
* by a s e c t i o n d e c l a r a t i o n . S i n c e t h i s h e a d e r i s n o t c o v e r e d b y a n y
* section, t h e d e b u g t a b l e m u s t b e e m i t t e d e l s e w h e r e . S o s t i c k i t i n
* the . i n i t . r o d a t a s e c t i o n i n s t e a d .
*
* Note t h a t t h e E F I d e b u g e n t r y i t s e l f m a y l e g a l l y h a v e a z e r o R V A ,
* which m e a n s w e c a n s i m p l y p u t i t r i g h t a f t e r t h e s e c t i o n h e a d e r s .
* /
_ _ INITRODATA
.align 2
efi_debug_table :
/ / EFI_ I M A G E _ D E B U G _ D I R E C T O R Y _ E N T R Y
.long 0 / / Characteristics
.long 0 / / TimeDateStamp
.short 0 / / MajorVersion
.short 0 / / MinorVersion
2017-03-23 19:00:50 +00:00
.long IMAGE_DEBUG_TYPE_CODEVIEW / / Type
2017-03-23 19:00:46 +00:00
.long efi_debug_entry_size / / SizeOfData
.long 0 / / RVA
.long efi_debug_entry - _ head / / F i l e O f f s e t
.set efi_ d e b u g _ t a b l e _ s i z e , . - e f i _ d e b u g _ t a b l e
.previous
efi_debug_entry :
/ / EFI_ I M A G E _ D E B U G _ C O D E V I E W _ N B 1 0 _ E N T R Y
.ascii " NB1 0 " / / S i g n a t u r e
.long 0 / / Unknown
.long 0 / / Unknown2
.long 0 / / Unknown3
.asciz VMLINUX_PATH
.set efi_ d e b u g _ e n t r y _ s i z e , . - e f i _ d e b u g _ e n t r y
# endif
/ *
* EFI w i l l l o a d . t e x t o n w a r d s a t t h e 4 k s e c t i o n a l i g n m e n t
* described i n t h e P E / C O F F h e a d e r . T o e n s u r e t h a t i n s t r u c t i o n
* sequences u s i n g a n a d r p a n d a : l o 1 2 : i m m e d i a t e w i l l f u n c t i o n
* correctly a t t h i s a l i g n m e n t , w e m u s t e n s u r e t h a t . t e x t i s
* placed a t a 4 k b o u n d a r y i n t h e I m a g e t o b e g i n w i t h .
* /
.align 12
efi_header_end :
.endm