Hi Tom,

arch/arm/cpu/armv8/u-boot.lds and arch/arm/mach-omap2/u-boot-spl.lds
can use the same alignment. Is the omap2 case covered by the TI
patches? I think it's better if you bundle this up in this series

Cheers
/Ilias

On Fri, 16 Jan 2026 at 00:28, Tom Rini <[email protected]> wrote:
>
> With commit 0535e46d55d7 ("scripts/dtc: Update to upstream version
> v1.7.2-35-g52f07dcca47c") it is now a fatal error to U-Boot if our
> device tree is not 8-byte aligned. In commit f613a6e15ef7 ("ARM: OMAP2+:
> Pad SPL binary to 8-byte alignment before DTB") Beleswar Padhi explains
> that we must have ALIGN(x) statements inside of a section to ensure that
> padding is included and not simply that the linker address counter is
> incremented. To that end, this patch:
> - Expands some linker sections to be more readable when adding a second
>   statement to the section.
> - Aligns the final section before _end (for U-Boot) or
>   _image_binary_end or __bss_end (for xPL phases) by 8-bytes by adding
>   '. = ALIGN(8);' to the final section before the symbol.
> - Ensure that we do have alignment by adding an ASSERT so that when not
>   aligned we fail to link (and explain why).
> - Remove now-spurious  '. = ALIGN(x);' statements that were intended to
>   provide the above alignments.
>
> Signed-off-by: Tom Rini <[email protected]>
> ---
> The only part of this I am only mostly rather than fully confident in is
> having caught all cases of having SPL_SEPARATE_BSS being false. I
> believe I have as the generic ARM SPL linker script enforces the BSS
> ending with 8-byte alignment, and the point of the ASSERTs here is to
> catch the case where the section we're adding the ALIGN to ends up being
> empty and so that ALIGN would become useless.
>
> Cc: "NXP i.MX U-Boot Team" <[email protected]>
> Cc: Adam Ford <[email protected]>
> Cc: Andre Przywara <[email protected]>
> Cc: Aspeed BMC SW team <[email protected]>
> Cc: Chia-Wei Wang <[email protected]>
> Cc: Eugen Hristev <[email protected]>
> Cc: Fabio Estevam <[email protected]>
> Cc: Ilias Apalodimas <[email protected]>
> Cc: Jagan Teki <[email protected]>
> Cc: Joel Stanley <[email protected]>
> Cc: Kever Yang <[email protected]>
> Cc: Marek Vasut <[email protected]>
> Cc: Michal Simek <[email protected]>
> Cc: Philipp Tomsich <[email protected]>
> Cc: Richard Henderson <[email protected]>
> Cc: Ryan Chen <[email protected]>
> Cc: Stefano Babic <[email protected]>
> ---
>  arch/arm/cpu/arm1136/u-boot-spl.lds            | 8 ++++++--
>  arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds      | 5 ++++-
>  arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds    | 5 ++++-
>  arch/arm/cpu/armv7/sunxi/u-boot-spl.lds        | 5 ++++-
>  arch/arm/cpu/armv8/u-boot-spl.lds              | 4 +++-
>  arch/arm/cpu/armv8/u-boot.lds                  | 2 ++
>  arch/arm/cpu/u-boot-spl.lds                    | 5 ++++-
>  arch/arm/cpu/u-boot.lds                        | 4 ++++
>  arch/arm/mach-aspeed/ast2600/u-boot-spl.lds    | 4 ++++
>  arch/arm/mach-at91/arm926ejs/u-boot-spl.lds    | 9 +++++++--
>  arch/arm/mach-at91/armv7/u-boot-spl.lds        | 9 +++++++--
>  arch/arm/mach-omap2/u-boot-spl.lds             | 3 +++
>  arch/arm/mach-rockchip/u-boot-tpl-v8.lds       | 5 ++++-
>  arch/arm/mach-zynq/u-boot-spl.lds              | 6 ++++--
>  arch/arm/mach-zynq/u-boot.lds                  | 3 +++
>  board/davinci/da8xxevm/u-boot-spl-da850evm.lds | 4 ++++
>  board/samsung/common/exynos-uboot-spl.lds      | 5 ++++-
>  17 files changed, 71 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm/cpu/arm1136/u-boot-spl.lds 
> b/arch/arm/cpu/arm1136/u-boot-spl.lds
> index b7af29183a97..22a9302275ae 100644
> --- a/arch/arm/cpu/arm1136/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm1136/u-boot-spl.lds
> @@ -30,8 +30,10 @@ SECTIONS
>         .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
>
>         . = ALIGN(4);
> -       .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
> -       . = ALIGN(4);
> +       .data : {
> +               *(SORT_BY_ALIGNMENT(.data*))
> +               . = ALIGN(8);
> +       } >.sram
>         __image_copy_end = .;
>         _end = .;
>
> @@ -44,3 +46,5 @@ SECTIONS
>                 __bss_end = .;
>         } >.sdram
>  }
> +
> +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds 
> b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> index 7c6309246f8b..b4adae272eba 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> @@ -45,7 +45,7 @@ SECTIONS
>                 . = ALIGN(4);
>                 __bss_start = .;
>                 *(.bss*)
> -               . = ALIGN(4);
> +               . = ALIGN(8);
>                 __bss_end = .;
>         }
>
> @@ -62,3 +62,6 @@ SECTIONS
>         .gnu : { *(.gnu*) }
>         .ARM.exidx : { *(.ARM.exidx*) }
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds 
> b/arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds
> index cf65e8c46281..2225985c79c0 100644
> --- a/arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds
> @@ -31,9 +31,9 @@ SECTIONS
>         . = ALIGN(4);
>         __u_boot_list : {
>                 KEEP(*(SORT(__u_boot_list*)));
> +               . = ALIGN(8);
>         } > .sram
>
> -       . = ALIGN(4);
>         __image_copy_end = .;
>         _end = .;
>         _image_binary_end = .;
> @@ -47,3 +47,6 @@ SECTIONS
>                 __bss_end = .;
>         } > .sdram
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds 
> b/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
> index fb7a789b28b8..e69291d8be6d 100644
> --- a/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
> +++ b/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
> @@ -40,9 +40,9 @@ SECTIONS
>         . = ALIGN(4);
>         __u_boot_list : {
>                 KEEP(*(SORT(__u_boot_list*)));
> +               . = ALIGN(8);
>         } > .sram
>
> -       . = ALIGN(4);
>         __image_copy_end = .;
>         _end = .;
>         _image_binary_end = .;
> @@ -56,3 +56,6 @@ SECTIONS
>                 __bss_end = .;
>         } > .sdram
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/cpu/armv8/u-boot-spl.lds 
> b/arch/arm/cpu/armv8/u-boot-spl.lds
> index c4f83ec9cfc4..d9963846c4f4 100644
> --- a/arch/arm/cpu/armv8/u-boot-spl.lds
> +++ b/arch/arm/cpu/armv8/u-boot-spl.lds
> @@ -52,9 +52,9 @@ SECTIONS
>         __u_boot_list : {
>                 . = ALIGN(8);
>                 KEEP(*(SORT(__u_boot_list*)));
> +               . = ALIGN(8);
>         } >.sram
>
> -       . = ALIGN(8);
>         __image_copy_end = .;
>         _end = .;
>         _image_binary_end = .;
> @@ -89,5 +89,7 @@ SECTIONS
>  #endif
>  }
>
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
>  ASSERT(ADDR(.bss) % 8 == 0, \
>         ".bss must be 8-byte aligned");
> diff --git a/arch/arm/cpu/armv8/u-boot.lds b/arch/arm/cpu/armv8/u-boot.lds
> index f4ce98c82c8d..704e0bf9468d 100644
> --- a/arch/arm/cpu/armv8/u-boot.lds
> +++ b/arch/arm/cpu/armv8/u-boot.lds
> @@ -175,3 +175,5 @@ SECTIONS
>  #include "linux-kernel-image-header-vars.h"
>  #endif
>  }
> +
> +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds
> index 5aecb61ce902..d780a5060774 100644
> --- a/arch/arm/cpu/u-boot-spl.lds
> +++ b/arch/arm/cpu/u-boot-spl.lds
> @@ -51,9 +51,9 @@ SECTIONS
>                 __rel_dyn_start = .;
>                 *(.rel*)
>                 __rel_dyn_end = .;
> +               . = ALIGN(8);
>         }
>
> -       . = ALIGN(8);
>         _image_binary_end = .;
>         _end = .;
>
> @@ -80,6 +80,9 @@ ASSERT(__image_copy_end - __image_copy_start <= 
> (IMAGE_MAX_SIZE), \
>         "SPL image too big");
>  #endif
>
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> +
>  #if defined(CONFIG_SPL_BSS_MAX_SIZE)
>  ASSERT(__bss_end - __bss_start <= (CONFIG_SPL_BSS_MAX_SIZE), \
>         "SPL image BSS too big");
> diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds
> index 78aad093d3b2..8e2266a90fe2 100644
> --- a/arch/arm/cpu/u-boot.lds
> +++ b/arch/arm/cpu/u-boot.lds
> @@ -164,6 +164,7 @@ SECTIONS
>                 __rel_dyn_start = .;
>                 *(.rel*)
>                 __rel_dyn_end = .;
> +               . = ALIGN(8);
>         }
>
>         _end = .;
> @@ -192,3 +193,6 @@ SECTIONS
>         /DISCARD/ : { *(.ARM.exidx*) }
>         /DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/mach-aspeed/ast2600/u-boot-spl.lds 
> b/arch/arm/mach-aspeed/ast2600/u-boot-spl.lds
> index 9502a7384b53..c9664a6ce566 100644
> --- a/arch/arm/mach-aspeed/ast2600/u-boot-spl.lds
> +++ b/arch/arm/mach-aspeed/ast2600/u-boot-spl.lds
> @@ -59,6 +59,7 @@ SECTIONS
>                 __rel_dyn_start = .;
>                 *(.rel*)
>                 __rel_dyn_end = .;
> +               . = ALIGN(8);
>         } > .nor
>
>         _end = .;
> @@ -79,6 +80,9 @@ ASSERT(__image_copy_end - __image_copy_start <= 
> (IMAGE_MAX_SIZE), \
>         "SPL image too big");
>  #endif
>
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> +
>  #if defined(CONFIG_SPL_BSS_MAX_SIZE)
>  ASSERT(__bss_end - __bss_start <= (CONFIG_SPL_BSS_MAX_SIZE), \
>         "SPL image BSS too big");
> diff --git a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds 
> b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
> index 09cf838cf96e..1af4f7b6524c 100644
> --- a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
> +++ b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
> @@ -29,9 +29,11 @@ SECTIONS
>         .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
>
>         . = ALIGN(4);
> -       __u_boot_list : { KEEP(*(SORT(__u_boot_list*))) } > .sram
> +       __u_boot_list : {
> +               KEEP(*(SORT(__u_boot_list*)))
> +               . = ALIGN(8);
> +       } > .sram
>
> -       . = ALIGN(4);
>         __image_copy_end = .;
>         _end = .;
>         _image_binary_end = .;
> @@ -51,6 +53,9 @@ ASSERT(__image_copy_end - __start <= (IMAGE_MAX_SIZE), \
>         "SPL image too big");
>  #endif
>
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> +
>  #if defined(CONFIG_SPL_BSS_MAX_SIZE)
>  ASSERT(__bss_end - __bss_start <= (CONFIG_SPL_BSS_MAX_SIZE), \
>         "SPL image BSS too big");
> diff --git a/arch/arm/mach-at91/armv7/u-boot-spl.lds 
> b/arch/arm/mach-at91/armv7/u-boot-spl.lds
> index 460a91d93ec4..287764df48ff 100644
> --- a/arch/arm/mach-at91/armv7/u-boot-spl.lds
> +++ b/arch/arm/mach-at91/armv7/u-boot-spl.lds
> @@ -36,9 +36,11 @@ SECTIONS
>         .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
>
>         . = ALIGN(4);
> -       __u_boot_list : { KEEP(*(SORT(__u_boot_list*))) } > .sram
> +       __u_boot_list : {
> +               KEEP(*(SORT(__u_boot_list*)))
> +               . = ALIGN(8);
> +       } > .sram
>
> -       . = ALIGN(4);
>         __image_copy_end = .;
>         _end = .;
>         _image_binary_end = .;
> @@ -52,3 +54,6 @@ SECTIONS
>                 __bss_end = .;
>         } >.sdram
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/mach-omap2/u-boot-spl.lds 
> b/arch/arm/mach-omap2/u-boot-spl.lds
> index 5ad169a37b73..86ab692ae390 100644
> --- a/arch/arm/mach-omap2/u-boot-spl.lds
> +++ b/arch/arm/mach-omap2/u-boot-spl.lds
> @@ -55,3 +55,6 @@ SECTIONS
>                 __bss_end = .;
>         } >.sdram
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/mach-rockchip/u-boot-tpl-v8.lds 
> b/arch/arm/mach-rockchip/u-boot-tpl-v8.lds
> index 958a1b70aefe..2c0f5c3e5f32 100644
> --- a/arch/arm/mach-rockchip/u-boot-tpl-v8.lds
> +++ b/arch/arm/mach-rockchip/u-boot-tpl-v8.lds
> @@ -42,9 +42,9 @@ SECTIONS
>         __u_boot_list : {
>                 . = ALIGN(8);
>                 KEEP(*(SORT(__u_boot_list*)));
> +               . = ALIGN(8);
>         }
>
> -       . = ALIGN(8);
>         __image_copy_end = .;
>         _end = .;
>         _image_binary_end = .;
> @@ -69,6 +69,9 @@ ASSERT(__image_copy_end - __image_copy_start < 
> (CONFIG_TPL_MAX_SIZE), \
>         "TPL image too big");
>  #endif
>
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> +
>  #if defined(CONFIG_TPL_BSS_MAX_SIZE)
>  ASSERT(__bss_end - __bss_start < (CONFIG_TPL_BSS_MAX_SIZE), \
>         "TPL image BSS too big");
> diff --git a/arch/arm/mach-zynq/u-boot-spl.lds 
> b/arch/arm/mach-zynq/u-boot-spl.lds
> index d96a57702886..17f0d7c9b72f 100644
> --- a/arch/arm/mach-zynq/u-boot-spl.lds
> +++ b/arch/arm/mach-zynq/u-boot-spl.lds
> @@ -39,10 +39,9 @@ SECTIONS
>         . = ALIGN(4);
>         __u_boot_list : {
>                 KEEP(*(SORT(__u_boot_list*)));
> +               . = ALIGN(8);
>         } > .sram
>
> -       . = ALIGN(4);
> -
>         _image_binary_end = .;
>
>         _end = .;
> @@ -62,3 +61,6 @@ SECTIONS
>         /DISCARD/ : { *(.interp*) }
>         /DISCARD/ : { *(.gnu*) }
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/arch/arm/mach-zynq/u-boot.lds b/arch/arm/mach-zynq/u-boot.lds
> index f52523edf490..2a8e3399e0bf 100644
> --- a/arch/arm/mach-zynq/u-boot.lds
> +++ b/arch/arm/mach-zynq/u-boot.lds
> @@ -66,6 +66,7 @@ SECTIONS
>                 __rel_dyn_start = .;
>                 *(.rel*)
>                 __rel_dyn_end = .;
> +               . = ALIGN(8);
>         }
>
>         _end = .;
> @@ -98,3 +99,5 @@ SECTIONS
>         /DISCARD/ : { *(.ARM.exidx*) }
>         /DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
>  }
> +
> +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");
> diff --git a/board/davinci/da8xxevm/u-boot-spl-da850evm.lds 
> b/board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> index 56d6f4f114b9..d1a82e118af1 100644
> --- a/board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> +++ b/board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> @@ -43,6 +43,7 @@ SECTIONS
>                 __rel_dyn_start = .;
>                 *(.rel*)
>                 __rel_dyn_end = .;
> +               . = ALIGN(8);
>         } >.sram
>
>         __image_copy_end = .;
> @@ -58,3 +59,6 @@ SECTIONS
>                 __bss_end = .;
>         } >.sdram
>  }
> +
> +ASSERT(_image_binary_end % 8 == 0, \
> +       "_image_binary_end must be 8-byte aligned for device tree");
> diff --git a/board/samsung/common/exynos-uboot-spl.lds 
> b/board/samsung/common/exynos-uboot-spl.lds
> index 9d3b57e98dbb..62e150bcf335 100644
> --- a/board/samsung/common/exynos-uboot-spl.lds
> +++ b/board/samsung/common/exynos-uboot-spl.lds
> @@ -48,7 +48,10 @@ SECTIONS
>                 . = ALIGN(4);
>                 __bss_start = .;
>                 *(.bss*)
> -               . = ALIGN(4);
> +               . = ALIGN(8);
>                 __bss_end = .;
>         } >.sram
>  }
> +
> +ASSERT(__bss_end % 8 == 0, \
> +       "__bss_end must be 8-byte aligned for device tree");
> --
> 2.43.0
>

Reply via email to