diff mbox series

[4/4] arm: EFI linker script text section alignment

Message ID 20240509143743.1496210-5-raymond.mao@linaro.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series Clean-up patch set for MbedTLS integration | expand

Commit Message

Raymond Mao May 9, 2024, 2:37 p.m. UTC
Add text section alignment to fix sbsign signing warning
'gaps in the section table may result in different checksums'
which causes a failure of efi_image_verify_diges()

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
---
 arch/arm/lib/elf_aarch64_efi.lds | 1 +
 1 file changed, 1 insertion(+)

Comments

Ilias Apalodimas May 9, 2024, 6:15 p.m. UTC | #1
Hi Raymond,

Try not to post the same patches without the fixes that were asked
[0], at least not without an explanation.

On Thu, 9 May 2024 at 17:38, Raymond Mao <raymond.mao@linaro.org> wrote:
>
> Add text section alignment to fix sbsign signing warning
> 'gaps in the section table may result in different checksums'
> which causes a failure of efi_image_verify_diges()
>
> Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
> ---
>  arch/arm/lib/elf_aarch64_efi.lds | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/lib/elf_aarch64_efi.lds b/arch/arm/lib/elf_aarch64_efi.lds
> index 5dd98091698..bffd9a0447a 100644
> --- a/arch/arm/lib/elf_aarch64_efi.lds
> +++ b/arch/arm/lib/elf_aarch64_efi.lds
> @@ -28,6 +28,7 @@ SECTIONS
>                 *(.dynamic);
>                 . = ALIGN(512);
>         }
> +       . = ALIGN(4096);

This is not what you want. There's already an ALIGN a few lines below
and you must include the symbols for _etext and _text_size.
You have to move the rela.* sections after the alignment. IIRC those
were inspired by [1], so you can look for guidance there.
On top of that riscv will need similar fixes (and any other
architecture that uses those)


>         .rela.dyn : { *(.rela.dyn) }
>         .rela.plt : { *(.rela.plt) }
>         .rela.got : { *(.rela.got) }
> --
> 2.25.1
>

[0] https://lore.kernel.org/u-boot/CAC_iWjK+14L6mEi8GQN-McF-SChvhnjJ79nE1tWLV+kgWZKVew@mail.gmail.com/
[1] https://git.code.sf.net/p/gnu-efi/code

/Ilias
Raymond Mao May 10, 2024, 4:32 p.m. UTC | #2
Hi Ilias,

On Thu, 9 May 2024 at 14:15, Ilias Apalodimas <ilias.apalodimas@linaro.org>
wrote:

> Hi Raymond,
>
> Try not to post the same patches without the fixes that were asked
> [0], at least not without an explanation.
>
> On Thu, 9 May 2024 at 17:38, Raymond Mao <raymond.mao@linaro.org> wrote:
> >
> > Add text section alignment to fix sbsign signing warning
> > 'gaps in the section table may result in different checksums'
> > which causes a failure of efi_image_verify_diges()
> >
> > Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
> > ---
> >  arch/arm/lib/elf_aarch64_efi.lds | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/arm/lib/elf_aarch64_efi.lds
> b/arch/arm/lib/elf_aarch64_efi.lds
> > index 5dd98091698..bffd9a0447a 100644
> > --- a/arch/arm/lib/elf_aarch64_efi.lds
> > +++ b/arch/arm/lib/elf_aarch64_efi.lds
> > @@ -28,6 +28,7 @@ SECTIONS
> >                 *(.dynamic);
> >                 . = ALIGN(512);
> >         }
> > +       . = ALIGN(4096);
>
> This is not what you want. There's already an ALIGN a few lines below
> and you must include the symbols for _etext and _text_size.
> You have to move the rela.* sections after the alignment. IIRC those
> were inspired by [1], so you can look for guidance there.
> On top of that riscv will need similar fixes (and any other
> architecture that uses those)
>
> In practice, I have to add  ALIGN(4096) for both `.rela.*` and `.data`,
otherwise it always prompts warning when signing the EFI image as
below and finally leads a failure when calling function
`efi_image_verify_digest()`.

```
warning: gap in section table:
    .text   : 0x00001000 - 0x00001c00,
    .data   : 0x00002000 - 0x00002200,
gaps in the section table may result in different checksums
warning: data remaining[7680 vs 12720]: gaps between PE/COFF sections?
```

I am not sure if RISC-V is working, never tried to build with that.
But arm32, x86 should be fine - they don't have the `.rela.*` sections and
text and data sections are well aligned.


> >         .rela.dyn : { *(.rela.dyn) }
> >         .rela.plt : { *(.rela.plt) }
> >         .rela.got : { *(.rela.got) }
> > --
> > 2.25.1
> >
>
> [0]
> https://lore.kernel.org/u-boot/CAC_iWjK+14L6mEi8GQN-McF-SChvhnjJ79nE1tWLV+kgWZKVew@mail.gmail.com/
> [1] https://git.code.sf.net/p/gnu-efi/code
>
>
Regards,
Raymond
diff mbox series

Patch

diff --git a/arch/arm/lib/elf_aarch64_efi.lds b/arch/arm/lib/elf_aarch64_efi.lds
index 5dd98091698..bffd9a0447a 100644
--- a/arch/arm/lib/elf_aarch64_efi.lds
+++ b/arch/arm/lib/elf_aarch64_efi.lds
@@ -28,6 +28,7 @@  SECTIONS
 		*(.dynamic);
 		. = ALIGN(512);
 	}
+	. = ALIGN(4096);
 	.rela.dyn : { *(.rela.dyn) }
 	.rela.plt : { *(.rela.plt) }
 	.rela.got : { *(.rela.got) }