arm: Update linker scripts to ensure appended device tree is aligned
With commit0535e46d55("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 commit85f586035d("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>
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user