From 50f909db8f53011b00c5819e593504264d23bb82 Mon Sep 17 00:00:00 2001 From: Vasily Gorbik Date: Thu, 12 Mar 2026 18:36:00 +0100 Subject: [PATCH] zipl/boot: Fix stage3 secure boot trailer placement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stage3 linker script places .sb.trailer so that it must end at COMMAND_LINE_EXTRA. The current script derives the start address from SIZEOF(.sb.trailer) before the section is emitted: . = COMMAND_LINE_EXTRA - SIZEOF(.sb.trailer); With binutils older than 2.39 before commit 648f6099d4dc ("-z relro relaxation and ld script SIZEOF") this can result in .sb.trailer being placed at COMMAND_LINE_EXTRA instead, moving the trailer into the following area and breaking the expected layout. The trailer has a fixed size, so use an explicit constant for the placement calculation and keep the ASSERT to verify the final section size. This makes the placement deterministic again. Fixes: a1126352ecfa ("zipl/boot: Improve linker scripts") Reviewed-by: Marc Hartmayer Signed-off-by: Vasily Gorbik Signed-off-by: Jan Höppner --- zipl/boot/stage3.lds.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zipl/boot/stage3.lds.S b/zipl/boot/stage3.lds.S index 35ed32d2..cbfaaf0f 100644 --- a/zipl/boot/stage3.lds.S +++ b/zipl/boot/stage3.lds.S @@ -48,15 +48,16 @@ SECTIONS .rodata : {*(.rodata .rodata.*) } .data : { *(.data .data.*) } +#define SB_TRAILER_SIZE 32 /* Trailer needed for Secure Boot */ - . = COMMAND_LINE_EXTRA - SIZEOF(.sb.trailer); + . = COMMAND_LINE_EXTRA - SB_TRAILER_SIZE; .sb.trailer : { QUAD(0x0000c00000000000) QUAD(STAGE3_ENTRY + PSW_LOAD) QUAD(STAGE3_ENTRY) QUAD(0x000000207a49504c) } - ASSERT(SIZEOF(.sb.trailer) == 32, "Invalid .sb.trailer size") + ASSERT(SIZEOF(.sb.trailer) == SB_TRAILER_SIZE, "Invalid .sb.trailer size") . = COMMAND_LINE_EXTRA; .cmdline_extra : {