Skip to contentSkip to conversation

efi: Drop preprocessor directives from zboot.lds

PATCH In review Vitaly Kuznetsov 3 participants 6 messages Jun 6, 2025 – Jul 8, 2025 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: Drop preprocessor directives from zboot.lds

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")

---
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(-)
drivers/firmware/efi/libstub/zboot.lds +0 -2
index c3a166675450..4b8d5cd3dfa2 100644
@@ -29,14 +29,12 @@ SECTIONS
 		. = _etext;
 	}
 
-#ifdef CONFIG_EFI_SBAT
         .sbat : ALIGN(4096) {
 		_sbat = .;
 		*(.sbat)
 		_esbat = ALIGN(4096);
 		. = _esbat;
 	}
-#endif
 
 	.data : ALIGN(4096) {
 		_data = .;
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Vitaly Kuznetsov

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:

Quoted 8 lines
 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")

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

I'll queue this as a fix.

Quoted 30 lines

---
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(-)
drivers/firmware/efi/libstub/zboot.lds +0 -3
index c3a166675450..4b8d5cd3dfa2 100644
@@ -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

Tested-by on v1 1/1
#2 lore raw
In reply to Vitaly Kuznetsov
Quoted 14 lines · Vitaly Kuznetsov

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:

Quoted 8 lines
  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")

Thanks for fixing Vitaly:

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

Quoted 26 lines

---
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(-)
drivers/firmware/efi/libstub/zboot.lds +0 -2
index c3a166675450..4b8d5cd3dfa2 100644
@@ -29,14 +29,12 @@ SECTIONS
  		. = _etext;
  	}
 
-#ifdef CONFIG_EFI_SBAT
          .sbat : ALIGN(4096) {
  		_sbat = .;
  		*(.sbat)
  		_esbat = ALIGN(4096);
  		. = _esbat;
  	}
-#endif
 
  	.data : ALIGN(4096) {
  		_data = .;
#3 lore raw
Quoted 21 lines · Luiz Capitulino
Quoted 20 lines · Vitaly Kuznetsov

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

Quoted 8 lines
Quoted 2 lines
Fixes 0f9a1739dd0e ("efi: zboot specific mechanism for embedding SBAT section")

Thanks for fixing Vitaly:

(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.

Quoted 26 lines
Quoted 25 lines

---
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(-)
drivers/firmware/efi/libstub/zboot.lds +0 -2
index c3a166675450..4b8d5cd3dfa2 100644
@@ -29,14 +29,12 @@ SECTIONS
           . = _etext;
       }
-#ifdef CONFIG_EFI_SBAT
           .sbat : ALIGN(4096) {
           _sbat = .;
           *(.sbat)
           _esbat = ALIGN(4096);
           . = _esbat;
       }
-#endif
       .data : ALIGN(4096) {
           _data = .;
maintainer
#4 lore raw
Quoted 28 lines · Luiz Capitulino
Quoted 26 lines · Luiz Capitulino
Quoted 14 lines · Vitaly Kuznetsov

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:

Quoted 8 lines
  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")

Thanks for fixing Vitaly:

Quoted 9 lines
Quoted 3 lines

(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.

#5 lore raw
Quoted 33 lines · Ard Biesheuvel
Quoted 32 lines · Luiz Capitulino
Quoted 29 lines · Luiz Capitulino
Quoted 14 lines · Vitaly Kuznetsov

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:

Quoted 8 lines
   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")

Thanks for fixing Vitaly:

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

Quoted 8 lines
Quoted 5 lines

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!