Hi!

On 4/16/21 6:43 PM, John Paul Adrian Glaubitz wrote:
> It seems the patch no longer applies due to the changes introduced by the 
> --sbat
> option [1].

I have manually rebased the patch like this. Rebuilding GRUB with that change
fixes the problem for me. So you'll just have to rebase your patch and we should
be good to go.

--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -841,7 +841,7 @@ init_pe_section(const struct grub_install_image_target_desc 
*image_target,
 
   section->raw_data_offset = grub_host_to_target32 (*rda);
   section->raw_data_size = grub_host_to_target32 (rsz);
-  (*rda) = ALIGN_UP (*rda + rsz, GRUB_PE32_FILE_ALIGNMENT);
+  (*rda) = *rda + rsz;
 
   section->characteristics = grub_host_to_target32 (characteristics);
 
@@ -1418,15 +1418,15 @@ grub_install_generate_image (const char *dir, const 
char *prefix,
 
        section = init_pe_section (image_target, section, ".data",
                                   &vma, scn_size, image_target->section_align,
-                                  &raw_data, scn_size,
+                                  &raw_data, layout.kernel_size - 
layout.exec_size,
                                   GRUB_PE32_SCN_CNT_INITIALIZED_DATA |
                                   GRUB_PE32_SCN_MEM_READ |
                                   GRUB_PE32_SCN_MEM_WRITE);
 
-       scn_size = pe_size - layout.reloc_size - sbat_size - raw_data;
+       scn_size = ALIGN_UP (pe_size - layout.reloc_size - sbat_size - 
raw_data, GRUB_PE32_FILE_ALIGNMENT);
        section = init_pe_section (image_target, section, "mods",
                                   &vma, scn_size, image_target->section_align,
-                                  &raw_data, scn_size,
+                                  &raw_data, pe_size - layout.reloc_size - 
raw_data,
                                   GRUB_PE32_SCN_CNT_INITIALIZED_DATA |
                                   GRUB_PE32_SCN_MEM_READ |
                                   GRUB_PE32_SCN_MEM_WRITE);
@@ -1444,13 +1444,13 @@ grub_install_generate_image (const char *dir, const 
char *prefix,
                                       GRUB_PE32_SCN_MEM_READ);
          }
 
-       scn_size = layout.reloc_size;
+       scn_size = ALIGN_UP (layout.reloc_size, GRUB_PE32_FILE_ALIGNMENT);
        PE_OHDR (o32, o64, base_relocation_table.rva) = grub_host_to_target32 
(vma);
        PE_OHDR (o32, o64, base_relocation_table.size) = grub_host_to_target32 
(scn_size);
        memcpy (pe_img + raw_data, layout.reloc_section, scn_size);
        init_pe_section (image_target, section, ".reloc",
                         &vma, scn_size, image_target->section_align,
-                        &raw_data, scn_size,
+                        &raw_data, layout.reloc_size,
                         GRUB_PE32_SCN_CNT_INITIALIZED_DATA |
                         GRUB_PE32_SCN_MEM_DISCARDABLE |
                         GRUB_PE32_SCN_MEM_READ);

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to