From: Stephen Warren <swar...@nvidia.com>

If the SPL extends beyond CONFIG_SYS_TEXT_BASE, then it will likely
corrupt the main U-Boot binary during execution, causing the main U-Boot
binary to fail. Check for this situation during the build to avoid
extremely annoying and hard-to-find bugs. Note that checking the size of
u-boot-spl.bin is not enough, since BSS size doesn't affect the size of
u-boot-spl.bin.

Signed-off-by: Stephen Warren <swar...@nvidia.com>
---
 Makefile |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 425adf4..2c2d8b6 100644
--- a/Makefile
+++ b/Makefile
@@ -522,6 +522,11 @@ dtbfile=
 endif
 
 $(obj)u-boot-$(nodtb)-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin 
$(dtbfile)
+               ebss=`${CROSS_COMPILE}objdump -t spl/u-boot-spl|awk 
'/__bss_end__/ {print "0x"$$1}'` ; \
+               if [ $$(($$ebss)) -gt $$(($(CONFIG_SYS_TEXT_BASE))) ]; then \
+                       echo ERROR: SPL BSS ends beyond CONFIG_SYS_TEXT_BASE > 
/dev/stderr; \
+                       exit 1; \
+               fi
                $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O 
binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
                cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin $(dtbfile) > 
$@
                rm $(obj)spl/u-boot-spl-pad.bin
-- 
1.7.0.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to