linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi: Drop preprocessor directives from zboot.lds
@ 2025-06-06 15:41 Vitaly Kuznetsov
  2025-06-06 15:53 ` Ard Biesheuvel
  2025-06-06 15:55 ` Luiz Capitulino
  0 siblings, 2 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2025-06-06 15:41 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Luiz Capitulino, linux-efi, linux-kernel

Older versions of `ld` don't seem to support preprocessor directives in
linker scripts, e.g. on RHEL9's ld-2.35.2-63.el9 the build fails with:

 ld:./drivers/firmware/efi/libstub/zboot.lds:32: ignoring invalid character `#' in expression
 ld:./drivers/firmware/efi/libstub/zboot.lds:33: syntax error

We don't seem to need these '#ifdef', no empty .sbat section is created
when CONFIG_EFI_SBAT_FILE="":

 # objdump -h arch/arm64/boot/vmlinuz.efi

 arch/arm64/boot/vmlinuz.efi:     file format pei-aarch64-little

 Sections:
 Idx Name          Size      VMA               LMA               File off  Algn
   0 .text         00b94000  0000000000001000  0000000000001000  00001000  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   1 .data         00000200  0000000000b95000  0000000000b95000  00b95000  2**2
                   CONTENTS, ALLOC, LOAD, DATA

Fixes: 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Note: not-yet-merged x86 version of 0f9a1739dd0e does not seem to be affected
as vmlinux.lds script is a pre-processed version of vmlinux.lds.S.
---
 drivers/firmware/efi/libstub/zboot.lds | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
index c3a166675450..4b8d5cd3dfa2 100644
--- a/drivers/firmware/efi/libstub/zboot.lds
+++ b/drivers/firmware/efi/libstub/zboot.lds
@@ -29,14 +29,12 @@ SECTIONS
 		. = _etext;
 	}
 
-#ifdef CONFIG_EFI_SBAT
         .sbat : ALIGN(4096) {
 		_sbat = .;
 		*(.sbat)
 		_esbat = ALIGN(4096);
 		. = _esbat;
 	}
-#endif
 
 	.data : ALIGN(4096) {
 		_data = .;
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] efi: Drop preprocessor directives from zboot.lds
  2025-06-06 15:41 [PATCH] efi: Drop preprocessor directives from zboot.lds Vitaly Kuznetsov
@ 2025-06-06 15:53 ` Ard Biesheuvel
  2025-06-06 15:55 ` Luiz Capitulino
  1 sibling, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2025-06-06 15:53 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: Luiz Capitulino, linux-efi, linux-kernel

On Fri, 6 Jun 2025 at 17:41, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Older versions of `ld` don't seem to support preprocessor directives in
> linker scripts, e.g. on RHEL9's ld-2.35.2-63.el9 the build fails with:
>
>  ld:./drivers/firmware/efi/libstub/zboot.lds:32: ignoring invalid character `#' in expression
>  ld:./drivers/firmware/efi/libstub/zboot.lds:33: syntax error
>
> We don't seem to need these '#ifdef', no empty .sbat section is created
> when CONFIG_EFI_SBAT_FILE="":
>
>  # objdump -h arch/arm64/boot/vmlinuz.efi
>
>  arch/arm64/boot/vmlinuz.efi:     file format pei-aarch64-little
>
>  Sections:
>  Idx Name          Size      VMA               LMA               File off  Algn
>    0 .text         00b94000  0000000000001000  0000000000001000  00001000  2**2
>                    CONTENTS, ALLOC, LOAD, READONLY, CODE
>    1 .data         00000200  0000000000b95000  0000000000b95000  00b95000  2**2
>                    CONTENTS, ALLOC, LOAD, DATA
>
> Fixes: 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Ah yes, I failed to realize that zboot.lds is never preprocessed - I
did notice that the #ifdef is unnecessary here as LD ignores empty
sections.

So the fix is

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

I'll queue this as a fix.

> ---
> Note: not-yet-merged x86 version of 0f9a1739dd0e does not seem to be affected
> as vmlinux.lds script is a pre-processed version of vmlinux.lds.S.
> ---
>  drivers/firmware/efi/libstub/zboot.lds | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
> index c3a166675450..4b8d5cd3dfa2 100644
> --- a/drivers/firmware/efi/libstub/zboot.lds
> +++ b/drivers/firmware/efi/libstub/zboot.lds
> @@ -29,14 +29,12 @@ SECTIONS
>                 . = _etext;
>         }
>
> -#ifdef CONFIG_EFI_SBAT
>          .sbat : ALIGN(4096) {
>                 _sbat = .;
>                 *(.sbat)
>                 _esbat = ALIGN(4096);
>                 . = _esbat;
>         }
> -#endif
>
>         .data : ALIGN(4096) {
>                 _data = .;
> --
> 2.49.0
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efi: Drop preprocessor directives from zboot.lds
  2025-06-06 15:41 [PATCH] efi: Drop preprocessor directives from zboot.lds Vitaly Kuznetsov
  2025-06-06 15:53 ` Ard Biesheuvel
@ 2025-06-06 15:55 ` Luiz Capitulino
  2025-07-07 21:36   ` Luiz Capitulino
  1 sibling, 1 reply; 6+ messages in thread
From: Luiz Capitulino @ 2025-06-06 15:55 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Ard Biesheuvel; +Cc: linux-efi, linux-kernel

On 2025-06-06 11:41, Vitaly Kuznetsov wrote:
> Older versions of `ld` don't seem to support preprocessor directives in
> linker scripts, e.g. on RHEL9's ld-2.35.2-63.el9 the build fails with:
> 
>   ld:./drivers/firmware/efi/libstub/zboot.lds:32: ignoring invalid character `#' in expression
>   ld:./drivers/firmware/efi/libstub/zboot.lds:33: syntax error
> 
> We don't seem to need these '#ifdef', no empty .sbat section is created
> when CONFIG_EFI_SBAT_FILE="":
> 
>   # objdump -h arch/arm64/boot/vmlinuz.efi
> 
>   arch/arm64/boot/vmlinuz.efi:     file format pei-aarch64-little
> 
>   Sections:
>   Idx Name          Size      VMA               LMA               File off  Algn
>     0 .text         00b94000  0000000000001000  0000000000001000  00001000  2**2
>                     CONTENTS, ALLOC, LOAD, READONLY, CODE
>     1 .data         00000200  0000000000b95000  0000000000b95000  00b95000  2**2
>                     CONTENTS, ALLOC, LOAD, DATA
> 
> Fixes: 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Thanks for fixing Vitaly:

Tested-by: Luiz Capitulino <luizcap@redhat.com>

(this is for the build test, not SBAT testing).

> ---
> Note: not-yet-merged x86 version of 0f9a1739dd0e does not seem to be affected
> as vmlinux.lds script is a pre-processed version of vmlinux.lds.S.
> ---
>   drivers/firmware/efi/libstub/zboot.lds | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
> index c3a166675450..4b8d5cd3dfa2 100644
> --- a/drivers/firmware/efi/libstub/zboot.lds
> +++ b/drivers/firmware/efi/libstub/zboot.lds
> @@ -29,14 +29,12 @@ SECTIONS
>   		. = _etext;
>   	}
>   
> -#ifdef CONFIG_EFI_SBAT
>           .sbat : ALIGN(4096) {
>   		_sbat = .;
>   		*(.sbat)
>   		_esbat = ALIGN(4096);
>   		. = _esbat;
>   	}
> -#endif
>   
>   	.data : ALIGN(4096) {
>   		_data = .;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efi: Drop preprocessor directives from zboot.lds
  2025-06-06 15:55 ` Luiz Capitulino
@ 2025-07-07 21:36   ` Luiz Capitulino
  2025-07-07 23:51     ` Ard Biesheuvel
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Capitulino @ 2025-07-07 21:36 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Ard Biesheuvel; +Cc: linux-efi, linux-kernel

On 2025-06-06 11:55, Luiz Capitulino wrote:
> On 2025-06-06 11:41, Vitaly Kuznetsov wrote:
>> Older versions of `ld` don't seem to support preprocessor directives in
>> linker scripts, e.g. on RHEL9's ld-2.35.2-63.el9 the build fails with:
>>
>>   ld:./drivers/firmware/efi/libstub/zboot.lds:32: ignoring invalid character `#' in expression
>>   ld:./drivers/firmware/efi/libstub/zboot.lds:33: syntax error
>>
>> We don't seem to need these '#ifdef', no empty .sbat section is created
>> when CONFIG_EFI_SBAT_FILE="":
>>
>>   # objdump -h arch/arm64/boot/vmlinuz.efi
>>
>>   arch/arm64/boot/vmlinuz.efi:     file format pei-aarch64-little
>>
>>   Sections:
>>   Idx Name          Size      VMA               LMA               File off  Algn
>>     0 .text         00b94000  0000000000001000  0000000000001000  00001000  2**2
>>                     CONTENTS, ALLOC, LOAD, READONLY, CODE
>>     1 .data         00000200  0000000000b95000  0000000000b95000  00b95000  2**2
>>                     CONTENTS, ALLOC, LOAD, DATA
>>
>> Fixes: 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> 
> Thanks for fixing Vitaly:
> 
> Tested-by: Luiz Capitulino <luizcap@redhat.com>
> 
> (this is for the build test, not SBAT testing).

Vitaly, Ard,

Are we planning to include this fix for 6.16? I'm afraid we'll introduce a
regression if we don't include it.

> 
>> ---
>> Note: not-yet-merged x86 version of 0f9a1739dd0e does not seem to be affected
>> as vmlinux.lds script is a pre-processed version of vmlinux.lds.S.
>> ---
>>   drivers/firmware/efi/libstub/zboot.lds | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
>> index c3a166675450..4b8d5cd3dfa2 100644
>> --- a/drivers/firmware/efi/libstub/zboot.lds
>> +++ b/drivers/firmware/efi/libstub/zboot.lds
>> @@ -29,14 +29,12 @@ SECTIONS
>>           . = _etext;
>>       }
>> -#ifdef CONFIG_EFI_SBAT
>>           .sbat : ALIGN(4096) {
>>           _sbat = .;
>>           *(.sbat)
>>           _esbat = ALIGN(4096);
>>           . = _esbat;
>>       }
>> -#endif
>>       .data : ALIGN(4096) {
>>           _data = .;
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efi: Drop preprocessor directives from zboot.lds
  2025-07-07 21:36   ` Luiz Capitulino
@ 2025-07-07 23:51     ` Ard Biesheuvel
  2025-07-08  0:46       ` Luiz Capitulino
  0 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2025-07-07 23:51 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Vitaly Kuznetsov, linux-efi, linux-kernel

On Tue, 8 Jul 2025 at 07:36, Luiz Capitulino <luizcap@redhat.com> wrote:
>
> On 2025-06-06 11:55, Luiz Capitulino wrote:
> > On 2025-06-06 11:41, Vitaly Kuznetsov wrote:
> >> Older versions of `ld` don't seem to support preprocessor directives in
> >> linker scripts, e.g. on RHEL9's ld-2.35.2-63.el9 the build fails with:
> >>
> >>   ld:./drivers/firmware/efi/libstub/zboot.lds:32: ignoring invalid character `#' in expression
> >>   ld:./drivers/firmware/efi/libstub/zboot.lds:33: syntax error
> >>
> >> We don't seem to need these '#ifdef', no empty .sbat section is created
> >> when CONFIG_EFI_SBAT_FILE="":
> >>
> >>   # objdump -h arch/arm64/boot/vmlinuz.efi
> >>
> >>   arch/arm64/boot/vmlinuz.efi:     file format pei-aarch64-little
> >>
> >>   Sections:
> >>   Idx Name          Size      VMA               LMA               File off  Algn
> >>     0 .text         00b94000  0000000000001000  0000000000001000  00001000  2**2
> >>                     CONTENTS, ALLOC, LOAD, READONLY, CODE
> >>     1 .data         00000200  0000000000b95000  0000000000b95000  00b95000  2**2
> >>                     CONTENTS, ALLOC, LOAD, DATA
> >>
> >> Fixes: 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")
> >> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> >
> > Thanks for fixing Vitaly:
> >
> > Tested-by: Luiz Capitulino <luizcap@redhat.com>
> >
> > (this is for the build test, not SBAT testing).
>
> Vitaly, Ard,
>
> Are we planning to include this fix for 6.16? I'm afraid we'll introduce a
> regression if we don't include it.
>

Apologies, I let this sit for a bit longer than I intended. I'll send
out the PR today.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efi: Drop preprocessor directives from zboot.lds
  2025-07-07 23:51     ` Ard Biesheuvel
@ 2025-07-08  0:46       ` Luiz Capitulino
  0 siblings, 0 replies; 6+ messages in thread
From: Luiz Capitulino @ 2025-07-08  0:46 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Vitaly Kuznetsov, linux-efi, linux-kernel

On 2025-07-07 19:51, Ard Biesheuvel wrote:
> On Tue, 8 Jul 2025 at 07:36, Luiz Capitulino <luizcap@redhat.com> wrote:
>>
>> On 2025-06-06 11:55, Luiz Capitulino wrote:
>>> On 2025-06-06 11:41, Vitaly Kuznetsov wrote:
>>>> Older versions of `ld` don't seem to support preprocessor directives in
>>>> linker scripts, e.g. on RHEL9's ld-2.35.2-63.el9 the build fails with:
>>>>
>>>>    ld:./drivers/firmware/efi/libstub/zboot.lds:32: ignoring invalid character `#' in expression
>>>>    ld:./drivers/firmware/efi/libstub/zboot.lds:33: syntax error
>>>>
>>>> We don't seem to need these '#ifdef', no empty .sbat section is created
>>>> when CONFIG_EFI_SBAT_FILE="":
>>>>
>>>>    # objdump -h arch/arm64/boot/vmlinuz.efi
>>>>
>>>>    arch/arm64/boot/vmlinuz.efi:     file format pei-aarch64-little
>>>>
>>>>    Sections:
>>>>    Idx Name          Size      VMA               LMA               File off  Algn
>>>>      0 .text         00b94000  0000000000001000  0000000000001000  00001000  2**2
>>>>                      CONTENTS, ALLOC, LOAD, READONLY, CODE
>>>>      1 .data         00000200  0000000000b95000  0000000000b95000  00b95000  2**2
>>>>                      CONTENTS, ALLOC, LOAD, DATA
>>>>
>>>> Fixes: 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")
>>>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>>
>>> Thanks for fixing Vitaly:
>>>
>>> Tested-by: Luiz Capitulino <luizcap@redhat.com>
>>>
>>> (this is for the build test, not SBAT testing).
>>
>> Vitaly, Ard,
>>
>> Are we planning to include this fix for 6.16? I'm afraid we'll introduce a
>> regression if we don't include it.
>>
> 
> Apologies, I let this sit for a bit longer than I intended. I'll send
> out the PR today.

Thanks a lot, Ard!


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-08  0:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 15:41 [PATCH] efi: Drop preprocessor directives from zboot.lds Vitaly Kuznetsov
2025-06-06 15:53 ` Ard Biesheuvel
2025-06-06 15:55 ` Luiz Capitulino
2025-07-07 21:36   ` Luiz Capitulino
2025-07-07 23:51     ` Ard Biesheuvel
2025-07-08  0:46       ` Luiz Capitulino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).