From 90efb8d394de9df1ae2c20f5e25ffc2009dc7ec5 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:31 -0600 Subject: [PATCH 01/10] Makefile: Have binary_size_check report only first match of _image_binary_end If we have ASSERT macros that validate the position of _image_binary_end, our awk expression will report a string that causes the rest of our check to fail with garbage values. Have it exit after the first match to fix this. Signed-off-by: Tom Rini --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50737f93850..37cebd4f8ed 100644 --- a/Makefile +++ b/Makefile @@ -1583,7 +1583,7 @@ binary_size_check: u-boot-nodtb.bin FORCE map_size=$(shell cat u-boot.map | \ awk ' \ /_image_copy_start/ { start = $$1 } \ - /_image_binary_end/ { end = $$1 } \ + /_image_binary_end/ { end = $$1;exit } \ END { \ if (start != "" && end != "") \ print end " " start; \ From 8b0ebe054bb3334c6ca9bed018360b08d4ddc7a4 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:32 -0600 Subject: [PATCH 02/10] arm: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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. Tested-by: Michal Simek # Zynq Reviewed-by: Ilias Apalodimas [trini: Also update arch/arm/cpu/armv8/u-boot.lds as Ilas requested] Signed-off-by: Tom Rini --- 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 | 3 +++ 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, 72 insertions(+), 15 deletions(-) diff --git a/arch/arm/cpu/arm1136/u-boot-spl.lds b/arch/arm/cpu/arm1136/u-boot-spl.lds index b7af29183a9..22a9302275a 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 7c6309246f8..b4adae272eb 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 cf65e8c4628..2225985c79c 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 fb7a789b28b..e69291d8be6 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 c4f83ec9cfc..d9963846c4f 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 f4ce98c82c8..231ab28b50c 100644 --- a/arch/arm/cpu/armv8/u-boot.lds +++ b/arch/arm/cpu/armv8/u-boot.lds @@ -146,6 +146,7 @@ SECTIONS __rel_dyn_start = .; *(.rela*) __rel_dyn_end = .; + . = ALIGN(8); } _end = .; @@ -175,3 +176,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 5aecb61ce90..d780a506077 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 78aad093d3b..8e2266a90fe 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 9502a7384b5..c9664a6ce56 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 09cf838cf96..1af4f7b6524 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 460a91d93ec..287764df48f 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 3bb759d8a1c..b61e657900a 100644 --- a/arch/arm/mach-omap2/u-boot-spl.lds +++ b/arch/arm/mach-omap2/u-boot-spl.lds @@ -51,3 +51,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 958a1b70aef..2c0f5c3e5f3 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 d96a5770288..17f0d7c9b72 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 f52523edf49..2a8e3399e0b 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 56d6f4f114b..d1a82e118af 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 9d3b57e98db..62e150bcf33 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"); From dac67bf0bee168de8f43050fe9b1d776de1ee00f Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:33 -0600 Subject: [PATCH 03/10] m68k: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Remove part of what Marek Vasut did in commit 9ed99e2eeadb ("m68k: Assure end of U-Boot is at 8-byte aligned offset") as we now better understand what can trigger failure and check for it. - Rewrite the '.dynsym' section to follow modern practices, and include the 8-byte alignment at the end of the section. - Ensure that we do have alignment by adding an ASSERT so that when not aligned we fail to link (and explain why). Signed-off-by: Tom Rini --- arch/m68k/cpu/u-boot.lds | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/m68k/cpu/u-boot.lds b/arch/m68k/cpu/u-boot.lds index be1ad0170af..452003ff43c 100644 --- a/arch/m68k/cpu/u-boot.lds +++ b/arch/m68k/cpu/u-boot.lds @@ -69,28 +69,27 @@ SECTIONS __ex_table : { *(__ex_table) } __stop___ex_table = .; - . = ALIGN(8); + . = ALIGN(4); __init_begin = .; .text.init : { *(.text.init) } .data.init : { *(.data.init) } - . = ALIGN(8); + . = ALIGN(4); __init_end = .; - . = ALIGN(8); + . = ALIGN(4); __rel_dyn_start = .; .rela.dyn : { *(.rela.dyn) } __rel_dyn_end = .; - . = ALIGN(8); - __dyn_sym_start = .; - .dynsym : { + .dynsym ALIGN(4) : { + __dyn_sym_start = .; *(.dynsym) + __dyn_sym_end = .; + . = ALIGN(8); } - __dyn_sym_end = .; - . = ALIGN(8); _end = .; __bss_start = .; @@ -100,9 +99,11 @@ SECTIONS *(.bss*) *(.sbss*) *(COMMON) - . = ALIGN(8); + . = ALIGN(4); _ebss = .; } __bss_end = . ; PROVIDE (end = .); } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); From 2e52030584d069b702f8367ddd34b3a65f522806 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:34 -0600 Subject: [PATCH 04/10] microblaze: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Aligns the final section before _end (for U-Boot) or _image_binary_end (for xPL phases) by 8-bytes by adjusting the ALIGN(4) statement to be ALIGN(8) in 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). Tested-by: Michal Simek Reviewed-by: Ilias Apalodimas Signed-off-by: Tom Rini --- arch/microblaze/cpu/u-boot-spl.lds | 5 ++++- arch/microblaze/cpu/u-boot.lds | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/microblaze/cpu/u-boot-spl.lds b/arch/microblaze/cpu/u-boot-spl.lds index 09abbea84d0..620ef2c96db 100644 --- a/arch/microblaze/cpu/u-boot-spl.lds +++ b/arch/microblaze/cpu/u-boot-spl.lds @@ -50,7 +50,7 @@ SECTIONS *(.bss) *(.bss.*) *(COMMON) - . = ALIGN(4); + . = ALIGN(8); __bss_end = .; } _end = . ; @@ -61,3 +61,6 @@ SECTIONS ASSERT(_end - _start <= (CONFIG_SPL_MAX_FOOTPRINT), \ "SPL image plus BSS too big"); #endif + +ASSERT(_image_binary_end % 8 == 0, \ + "_image_binary_end must be 8-byte aligned for device tree"); diff --git a/arch/microblaze/cpu/u-boot.lds b/arch/microblaze/cpu/u-boot.lds index a2c8fb2e21c..70fa49c3171 100644 --- a/arch/microblaze/cpu/u-boot.lds +++ b/arch/microblaze/cpu/u-boot.lds @@ -67,8 +67,10 @@ SECTIONS *(.scommon) *(.bss*) *(COMMON) - . = ALIGN(4); + . = ALIGN(8); __bss_end = .; } _end = . ; } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); From b220a43f5ae69f1b258976691fe70414c4fc2259 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:35 -0600 Subject: [PATCH 05/10] mips: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Aligns the final section before _end (for U-Boot) or _image_binary_end (for xPL phases) by 8-bytes by adding '. = ALIGN(8);' to the final section before the symbol. For SPL we need this in two places to cover all build configurations. - Remove now-spurious '. = ALIGN(x);' statements that were intended to provide the above alignments. - Ensure that we do have alignment by adding an ASSERT so that when not aligned we fail to link (and explain why). Reviewed-by: Daniel Schwierzeck Signed-off-by: Tom Rini --- arch/mips/cpu/u-boot-spl.lds | 6 +++++- arch/mips/cpu/u-boot.lds | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/mips/cpu/u-boot-spl.lds b/arch/mips/cpu/u-boot-spl.lds index 310a5c5053b..ea2deed34f1 100644 --- a/arch/mips/cpu/u-boot-spl.lds +++ b/arch/mips/cpu/u-boot-spl.lds @@ -27,16 +27,17 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) *(SORT_BY_ALIGNMENT(.sdata*)) + . = ALIGN(8); } > .spl_mem #if defined(CONFIG_SPL_DM) || defined(CONFIG_SPL_LOADER_SUPPORT) . = ALIGN(4); __u_boot_list : { KEEP(*(SORT(__u_boot_list*))); + . = ALIGN(8); } > .spl_mem #endif - . = ALIGN(4); __image_copy_end = .; __image_copy_len = __image_copy_end - __text_start; @@ -123,3 +124,6 @@ SECTIONS *(.eh_frame) } } + +ASSERT(_image_binary_end % 8 == 0, \ + "_image_binary_end must be 8-byte aligned for device tree"); diff --git a/arch/mips/cpu/u-boot.lds b/arch/mips/cpu/u-boot.lds index 133ea05df3d..d59a48b7ef8 100644 --- a/arch/mips/cpu/u-boot.lds +++ b/arch/mips/cpu/u-boot.lds @@ -54,9 +54,9 @@ SECTIONS LONG(0xFFFFFFFF); FILL(0); . += CONFIG_MIPS_RELOCATION_TABLE_SIZE - 4; + . = ALIGN(8); } - . = ALIGN(8); _end = .; .bss __rel_start (OVERLAY) : { @@ -140,3 +140,5 @@ SECTIONS *(.eh_frame) } } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); From 546d84ca0cb367240c93aa3e3492be4dccf85332 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:36 -0600 Subject: [PATCH 06/10] nios2: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Aligns the final section before _end 8-bytes by adding '. = ALIGN(8);' to the final section before the symbol. - Remove a now-spurious '. = ALIGN(x);' statement that was intended to provide the above alignments. - Ensure that we do have alignment by adding an ASSERT so that when not aligned we fail to link (and explain why). Acked-by: Ilias Apalodimas Signed-off-by: Tom Rini --- arch/nios2/cpu/u-boot.lds | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds index 5b9e27d9406..fc366d44341 100644 --- a/arch/nios2/cpu/u-boot.lds +++ b/arch/nios2/cpu/u-boot.lds @@ -60,8 +60,8 @@ SECTIONS *(.sdata) *(.sdata.*) *(.gnu.linkonce.s.*) + . = ALIGN(8); } - . = ALIGN(4); _edata = .; PROVIDE (edata = .); @@ -124,3 +124,5 @@ SECTIONS .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); From 87d3780ebc242e28a180606f72335ce37d8bcca1 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:37 -0600 Subject: [PATCH 07/10] powerpc: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Aligns the final section before _end by 8-bytes by adding '. = ALIGN(8);' or changing an existing ALIGN(4) statement. - Ensure that we do have alignment by adding an ASSERT so that when not aligned we fail to link (and explain why). Signed-off-by: Tom Rini --- arch/powerpc/cpu/mpc83xx/u-boot.lds | 3 +++ arch/powerpc/cpu/mpc85xx/u-boot.lds | 4 +++- board/cssi/cmpc885/u-boot.lds | 3 +++ board/cssi/mcr3000/u-boot.lds | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/cpu/mpc83xx/u-boot.lds b/arch/powerpc/cpu/mpc83xx/u-boot.lds index 1a1e537b2a7..5becc4d236e 100644 --- a/arch/powerpc/cpu/mpc83xx/u-boot.lds +++ b/arch/powerpc/cpu/mpc83xx/u-boot.lds @@ -56,6 +56,7 @@ SECTIONS * _end - This is end of u-boot.bin image. * dtb will be appended here to make u-boot-dtb.bin */ + . = ALIGN(8); _end = .; . = ALIGN(4096); @@ -77,3 +78,5 @@ SECTIONS PROVIDE (end = .); } ENTRY(_start) + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); diff --git a/arch/powerpc/cpu/mpc85xx/u-boot.lds b/arch/powerpc/cpu/mpc85xx/u-boot.lds index 3af0dfdf336..3c9959bef09 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot.lds @@ -78,7 +78,7 @@ SECTIONS __init_begin = .; .text.init : { *(.text.init) } .data.init : { *(.data.init) } - . = ALIGN(4); + . = ALIGN(8); __init_end = .; _end = .; @@ -119,3 +119,5 @@ SECTIONS __bss_end = . ; PROVIDE (end = .); } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); diff --git a/board/cssi/cmpc885/u-boot.lds b/board/cssi/cmpc885/u-boot.lds index 167606357e0..da9cff64d46 100644 --- a/board/cssi/cmpc885/u-boot.lds +++ b/board/cssi/cmpc885/u-boot.lds @@ -72,6 +72,7 @@ SECTIONS * _end - This is end of u-boot.bin image. * dtb will be appended here to make u-boot-dtb.bin */ + . = ALIGN(8); _end = .; . = ALIGN(4096); @@ -93,3 +94,5 @@ SECTIONS PROVIDE (end = .); } ENTRY(_start) + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); diff --git a/board/cssi/mcr3000/u-boot.lds b/board/cssi/mcr3000/u-boot.lds index 66afdebc0f7..1fd98726b2a 100644 --- a/board/cssi/mcr3000/u-boot.lds +++ b/board/cssi/mcr3000/u-boot.lds @@ -72,6 +72,7 @@ SECTIONS * _end - This is end of u-boot.bin image. * dtb will be appended here to make u-boot-dtb.bin */ + . = ALIGN(8); _end = .; . = ALIGN(4096); @@ -93,3 +94,5 @@ SECTIONS PROVIDE (end = .); } ENTRY(_start) + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); From f150843499b3139c2358f5659411571399902d4a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:38 -0600 Subject: [PATCH 08/10] riscv: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Aligns the final section before _end (for U-Boot) or _image_binary_end (for xPL phases) by 8-bytes by adding '. = ALIGN(8);' to the final section before the symbol. - Remove a now-spurious '. = ALIGN(x);' statement that was intended to provide the above alignments. - Ensure that we do have alignment by adding an ASSERT so that when not aligned we fail to link (and explain why). Reviewed-by: Leo Yu-Chi Liang Reviewed-by: Ilias Apalodimas Signed-off-by: Tom Rini --- arch/riscv/cpu/u-boot-spl.lds | 4 ++++ arch/riscv/cpu/u-boot.lds | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/riscv/cpu/u-boot-spl.lds b/arch/riscv/cpu/u-boot-spl.lds index 0717833df55..35de28db8f3 100644 --- a/arch/riscv/cpu/u-boot-spl.lds +++ b/arch/riscv/cpu/u-boot-spl.lds @@ -43,6 +43,7 @@ SECTIONS __binman_sym_start = .; KEEP(*(SORT(.binman_sym*))); __binman_sym_end = .; + . = ALIGN(8); } > .spl_mem _end = .; @@ -56,3 +57,6 @@ SECTIONS __bss_end = .; } > .bss_mem } + +ASSERT(_image_binary_end % 8 == 0, \ + "_image_binary_end must be 8-byte aligned for device tree"); diff --git a/arch/riscv/cpu/u-boot.lds b/arch/riscv/cpu/u-boot.lds index b11ea8b56d2..c299c00fa29 100644 --- a/arch/riscv/cpu/u-boot.lds +++ b/arch/riscv/cpu/u-boot.lds @@ -73,10 +73,9 @@ SECTIONS __dyn_sym_start = .; *(.dynsym) __dyn_sym_end = .; + . = ALIGN(8); } - . = ALIGN(8); - _end = .; .bss : { @@ -86,3 +85,5 @@ SECTIONS __bss_end = .; } } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree"); From 94b81451890f42b422bb13b03e2c1034b9bfb43d Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:39 -0600 Subject: [PATCH 09/10] sandbox: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Aligns the final section before _image_binary_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). Signed-off-by: Tom Rini --- arch/sandbox/cpu/u-boot-spl.lds | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds index a81d66a6f2e..bd5a164b8c9 100644 --- a/arch/sandbox/cpu/u-boot-spl.lds +++ b/arch/sandbox/cpu/u-boot-spl.lds @@ -25,9 +25,13 @@ SECTIONS *(_u_boot_sandbox_getopt_start) KEEP(*(_u_boot_sandbox_getopt)) *(_u_boot_sandbox_getopt_end) + . = ALIGN(8); } _image_binary_end = .; } INSERT AFTER .data; + +ASSERT(_image_binary_end % 8 == 0, \ + "_image_binary_end must be 8-byte aligned for device tree"); From 410d31bae4b863eabd70adb22a0c9976bfe4fee3 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Jan 2026 16:19:40 -0600 Subject: [PATCH 10/10] x86: Update linker scripts to ensure appended device tree is aligned 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 85f586035d75 ("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: - Rewrite the '.rel.dyn' (u-boot.lds) to follow modern practices, and include the 8-byte alignment at the end of the section. - Expands the '.dynamic' section (u-boot-64.lds) 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 or changing an existing ALIGN(4) statement. - Ensure that we do have alignment by adding an ASSERT so that when not aligned we fail to link (and explain why). Signed-off-by: Tom Rini --- arch/x86/cpu/u-boot-64.lds | 6 ++++-- arch/x86/cpu/u-boot-spl.lds | 10 +++++++++- arch/x86/cpu/u-boot.lds | 11 ++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds index 00a6d869121..0c353c5d740 100644 --- a/arch/x86/cpu/u-boot-64.lds +++ b/arch/x86/cpu/u-boot-64.lds @@ -86,9 +86,11 @@ SECTIONS __rel_dyn_end = .; . = ALIGN(4); - .dynamic : { *(.dynamic) } + .dynamic : { + *(.dynamic) + . = ALIGN(8); + } - . = ALIGN(4); _end = .; .bss __rel_dyn_start (OVERLAY) : { diff --git a/arch/x86/cpu/u-boot-spl.lds b/arch/x86/cpu/u-boot-spl.lds index 50b4b160855..57cdce6d751 100644 --- a/arch/x86/cpu/u-boot-spl.lds +++ b/arch/x86/cpu/u-boot-spl.lds @@ -68,7 +68,7 @@ SECTIONS __bss_start = .; *(.bss*) *(COM*) - . = ALIGN(4); + . = ALIGN(8); __bss_end = .; } __bss_size = __bss_end - __bss_start; @@ -97,3 +97,11 @@ SECTIONS #endif } + +ASSERT(_image_binary_end % 8 == 0, \ + "_image_binary_end must be 8-byte aligned for device tree"); + +#if !CONFIG_IS_ENABLED(SEPARATE_BSS) +ASSERT(__bss_end % 8 == 0, \ + "__bss_end must be 8-byte aligned for device tree"); +#endif diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds index c418ff44aa0..ea070acd6a1 100644 --- a/arch/x86/cpu/u-boot.lds +++ b/arch/x86/cpu/u-boot.lds @@ -79,13 +79,12 @@ SECTIONS . = ALIGN(4); .dynsym : { *(.dynsym*) } - . = ALIGN(4); - __rel_dyn_start = .; - .rel.dyn : { + .rel.dyn ALIGN(4) : { + __rel_dyn_start = .; *(.rel*) + __rel_dyn_end = .; + . = ALIGN(8); } - __rel_dyn_end = .; - . = ALIGN(4); _end = .; .bss __rel_dyn_start (OVERLAY) : { @@ -120,3 +119,5 @@ SECTIONS #endif } + +ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");