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 <michal.simek@amd.com> # Zynq
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
[trini: Also update arch/arm/cpu/armv8/u-boot.lds as Ilas requested]
Signed-off-by: Tom Rini <trini@konsulko.com>
.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 = .;
__bss_end = .;
} >.sdram
}
+
+ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");
. = ALIGN(4);
__bss_start = .;
*(.bss*)
- . = ALIGN(4);
+ . = ALIGN(8);
__bss_end = .;
}
.gnu : { *(.gnu*) }
.ARM.exidx : { *(.ARM.exidx*) }
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
. = ALIGN(4);
__u_boot_list : {
KEEP(*(SORT(__u_boot_list*)));
+ . = ALIGN(8);
} > .sram
- . = ALIGN(4);
__image_copy_end = .;
_end = .;
_image_binary_end = .;
__bss_end = .;
} > .sdram
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
. = ALIGN(4);
__u_boot_list : {
KEEP(*(SORT(__u_boot_list*)));
+ . = ALIGN(8);
} > .sram
- . = ALIGN(4);
__image_copy_end = .;
_end = .;
_image_binary_end = .;
__bss_end = .;
} > .sdram
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
__u_boot_list : {
. = ALIGN(8);
KEEP(*(SORT(__u_boot_list*)));
+ . = ALIGN(8);
} >.sram
- . = ALIGN(8);
__image_copy_end = .;
_end = .;
_image_binary_end = .;
#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");
__rel_dyn_start = .;
*(.rela*)
__rel_dyn_end = .;
+ . = ALIGN(8);
}
_end = .;
#include "linux-kernel-image-header-vars.h"
#endif
}
+
+ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");
__rel_dyn_start = .;
*(.rel*)
__rel_dyn_end = .;
+ . = ALIGN(8);
}
- . = ALIGN(8);
_image_binary_end = .;
_end = .;
"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");
__rel_dyn_start = .;
*(.rel*)
__rel_dyn_end = .;
+ . = ALIGN(8);
}
_end = .;
/DISCARD/ : { *(.ARM.exidx*) }
/DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
__rel_dyn_start = .;
*(.rel*)
__rel_dyn_end = .;
+ . = ALIGN(8);
} > .nor
_end = .;
"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");
.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 = .;
"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");
.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 = .;
__bss_end = .;
} >.sdram
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
__bss_end = .;
} >.sdram
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
__u_boot_list : {
. = ALIGN(8);
KEEP(*(SORT(__u_boot_list*)));
+ . = ALIGN(8);
}
- . = ALIGN(8);
__image_copy_end = .;
_end = .;
_image_binary_end = .;
"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");
. = ALIGN(4);
__u_boot_list : {
KEEP(*(SORT(__u_boot_list*)));
+ . = ALIGN(8);
} > .sram
- . = ALIGN(4);
-
_image_binary_end = .;
_end = .;
/DISCARD/ : { *(.interp*) }
/DISCARD/ : { *(.gnu*) }
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
__rel_dyn_start = .;
*(.rel*)
__rel_dyn_end = .;
+ . = ALIGN(8);
}
_end = .;
/DISCARD/ : { *(.ARM.exidx*) }
/DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
}
+
+ASSERT(_end % 8 == 0, "_end must be 8-byte aligned for device tree");
__rel_dyn_start = .;
*(.rel*)
__rel_dyn_end = .;
+ . = ALIGN(8);
} >.sram
__image_copy_end = .;
__bss_end = .;
} >.sdram
}
+
+ASSERT(_image_binary_end % 8 == 0, \
+ "_image_binary_end must be 8-byte aligned for device tree");
. = 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");