]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
powerpc: Update linker scripts to ensure appended device tree is aligned
authorTom Rini <trini@konsulko.com>
Thu, 15 Jan 2026 22:19:37 +0000 (16:19 -0600)
committerTom Rini <trini@konsulko.com>
Tue, 20 Jan 2026 18:07:20 +0000 (12:07 -0600)
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 <trini@konsulko.com>
arch/powerpc/cpu/mpc83xx/u-boot.lds
arch/powerpc/cpu/mpc85xx/u-boot.lds
board/cssi/cmpc885/u-boot.lds
board/cssi/mcr3000/u-boot.lds

index 1a1e537b2a765dc9b35b38917b726f507beb04fc..5becc4d236ef4eae04be1b40943279b30b052d76 100644 (file)
@@ -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");
index 3af0dfdf336b9453535197e1a6af24c4359b265d..3c9959bef097160916a0af2a08bdf51a5e7feef9 100644 (file)
@@ -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");
index 167606357e0062bdf5622e1fe34258ae6615b5a0..da9cff64d465f5c3aa7cd1b22a25639a855ac649 100644 (file)
@@ -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");
index 66afdebc0f770075b5e1e8b33ff75aca40b36fcd..1fd98726b2a8b8570d85af271b7a1eefca86e303 100644 (file)
@@ -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");