Re: [RFC PATCH 1/3] efi/x86: Use symbolic constants in PE header instead of bare numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 20, 2020 at 12:06:47PM +0100, Ard Biesheuvel wrote:
> Replace bare numbers in the PE/COFF header structure with symbolic
> constants so they become self documenting.
> 
> Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> ---
>  arch/x86/boot/header.S | 60 ++++++++++----------
>  1 file changed, 31 insertions(+), 29 deletions(-)
> 
> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
> index 44aeb63ca6ae..9110b58aa2ec 100644
> --- a/arch/x86/boot/header.S
> +++ b/arch/x86/boot/header.S
> @@ -210,7 +200,10 @@ section_table:
>  	.long	0				# PointerToLineNumbers
>  	.word	0				# NumberOfRelocations
>  	.word	0				# NumberOfLineNumbers
> -	.long	0x60500020			# Characteristics (section flags)
> +	.long	IMAGE_SCN_CNT_CODE		| \
> +		IMAGE_SCN_MEM_READ		| \
> +		IMAGE_SCN_MEM_EXECUTE		| \
> +		IMAGE_SCN_ALIGN_16BYTES		# Characteristics

The IMAGE_SCN_ALIGN bits are marked as "valid only for object files".
Can they be removed?

>  
>  	#
>  	# The EFI application loader requires a relocation section
> @@ -228,7 +221,10 @@ section_table:
>  	.long	0				# PointerToLineNumbers
>  	.word	0				# NumberOfRelocations
>  	.word	0				# NumberOfLineNumbers
> -	.long	0x42100040			# Characteristics (section flags)
> +	.long	IMAGE_SCN_CNT_INITIALIZED_DATA	| \
> +		IMAGE_SCN_MEM_READ		| \
> +		IMAGE_SCN_MEM_DISCARDABLE	| \
> +		IMAGE_SCN_ALIGN_1BYTES		# Characteristics
>  
>  #ifdef CONFIG_EFI_MIXED
>  	#
> @@ -244,7 +240,10 @@ section_table:
>  	.long	0				# PointerToLineNumbers
>  	.word	0				# NumberOfRelocations
>  	.word	0				# NumberOfLineNumbers
> -	.long	0x42100040			# Characteristics (section flags)
> +	.long	IMAGE_SCN_CNT_INITIALIZED_DATA	| \
> +		IMAGE_SCN_MEM_READ		| \
> +		IMAGE_SCN_MEM_DISCARDABLE	| \
> +		IMAGE_SCN_ALIGN_1BYTES		# Characteristics
>  #endif
>  
>  	#
> @@ -263,7 +262,10 @@ section_table:
>  	.long	0				# PointerToLineNumbers
>  	.word	0				# NumberOfRelocations
>  	.word	0				# NumberOfLineNumbers
> -	.long	0x60500020			# Characteristics (section flags)
> +	.long	IMAGE_SCN_CNT_CODE		| \
> +		IMAGE_SCN_MEM_READ		| \
> +		IMAGE_SCN_MEM_EXECUTE		| \
> +		IMAGE_SCN_ALIGN_16BYTES		# Characteristics

The .text section contains data as well. Shouldn't it be marked
IMAGE_SCN_MEM_WRITE also?

>  
>  	.set	section_count, (. - section_table) / 40
>  #endif /* CONFIG_EFI_STUB */
> -- 
> 2.17.1
> 



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux