Re: [PATCH 14/16] x86/build: Make generated PE more spec compliant

From: Evgeniy Baskov
Date: Thu Oct 20 2022 - 09:07:35 EST


On 2022-10-19 10:39, Ard Biesheuvel wrote:
On Tue, 6 Sept 2022 at 12:42, Evgeniy Baskov <baskov@xxxxxxxxx> wrote:

Currently kernel image is not fully compliant PE image, so it may
fail to boot with stricter implementations of UEFI PE loaders.

Set minimal alignments and sizes specified by PE documentation [1]
referenced by UEFI specification [2]. Align PE header to 8 bytes.


Generate '.reloc' section with 2 entries and set reloc data directory.

Why?

It seems to me that I saw minimal size requirement in MS documentation,
but now I cannot find the proof of my words, so I've probably misread.
So I'll drop this change.



To make code more readable refactor tools/build.c:
- Use mmap() to access kernel image.
- Generate sections dynamically.
- Setup sections protection. Since we cannot fit every
needed section, set a part of protection flags
dynamically during initialization. This step is omitted
if CONFIG_EFI_DXE_MEM_ATTRIBUTES is not set.


If the commit log of a patch contains a bulleted list of the changes
that it implements, it is a very strong indicator that it needs to be
split up. Presenting this as a big ball of changes makes the life of a
reviewed unnecessarily hard.


Sorry for that, I'll try to separate this into several patches.