diff options
| author | Tom Rini <[email protected]> | 2026-01-20 10:19:48 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-01-20 12:07:25 -0600 |
| commit | 084faca1d73d2dc3b4081587aee0dd90be5b5346 (patch) | |
| tree | e93167adce7a54d42600405212e2abbdc9d857df | |
| parent | 85f586035d75132b2b60d5e593e1c0049f5d126a (diff) | |
| parent | 410d31bae4b863eabd70adb22a0c9976bfe4fee3 (diff) | |
Merge patch series "Update linker scripts to ensure appended device tree is correctly aligned"
Tom Rini <[email protected]> says:
This series builds on top of what Beleswar Padhi did in [1]. While
there's still discussion about the mkimage related parts, the linker
portion appears to the reliable path forward. An alternative that I had
mentioned before, and was part of previous discussions on this topic[2]
is in the end I believe not reliable enough. While we can take an output
file and pad it to where we think it needs to be, ultimately the linker
needs to place the symbol where we want it and if that isn't where we
pad to, we have a different problem. So what this series does (but each
commit message elaborates on the arch-specific linker scripts being
inconsistent) is make sure the linker script will place the required
symbol at 8-byte alignment, and then also use an ASSERT to fail the
build if this would not be true due to some unforseen event.
[1]: https://lore.kernel.org/u-boot/[email protected]/
[2]: https://source.denx.de/u-boot/u-boot/-/issues/30
Link: https://lore.kernel.org/r/[email protected]
34 files changed, 143 insertions, 41 deletions
@@ -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; \ 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 5ad169a37b7..86ab692ae39 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 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/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"); 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"); 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"); 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"); 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/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"); 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"); 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"); 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"); 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"); |
