diff options
author | Simon Glass | 2014-06-02 23:04:47 -0500 |
---|---|---|
committer | Tom Rini | 2014-06-11 15:25:39 -0500 |
commit | 89742924c8e1c003362b970a2d2998a61e1ca420 (patch) | |
tree | bb92fb4f05af8d229c13e066b74c92c42d4e215d /Makefile | |
parent | 6469a34678e77ae3e10dd8e5ced89b2c348b46ea (diff) | |
download | u-boot-89742924c8e1c003362b970a2d2998a61e1ca420.tar.gz u-boot-89742924c8e1c003362b970a2d2998a61e1ca420.tar.xz u-boot-89742924c8e1c003362b970a2d2998a61e1ca420.zip |
Check that u-boot.bin size looks correct
Check that the image size matches the size we get from u-boot.bin. If it
doesn't, that generally means that some extra sections are being added to
u-boot.bin, meaning that it is not possible to access data appended to
the U-Boot binary. This is used for device tree, so needs to work.
This problem was introduced by commit b02bfc4. By adding a test we can
prevent a reccurence.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -706,7 +706,7 @@ DO_STATIC_RELA = | |||
706 | endif | 706 | endif |
707 | 707 | ||
708 | # Always append ALL so that arch config.mk's can add custom ones | 708 | # Always append ALL so that arch config.mk's can add custom ones |
709 | ALL-y += u-boot.srec u-boot.bin System.map | 709 | ALL-y += u-boot.srec u-boot.bin System.map binary_size_check |
710 | 710 | ||
711 | ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin | 711 | ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin |
712 | ifeq ($(CONFIG_SPL_FSL_PBL),y) | 712 | ifeq ($(CONFIG_SPL_FSL_PBL),y) |
@@ -785,6 +785,18 @@ u-boot.hex u-boot.srec: u-boot FORCE | |||
785 | 785 | ||
786 | OBJCOPYFLAGS_u-boot.bin := -O binary | 786 | OBJCOPYFLAGS_u-boot.bin := -O binary |
787 | 787 | ||
788 | binary_size_check: u-boot.bin System.map FORCE | ||
789 | @file_size=`stat -c %s u-boot.bin` ; \ | ||
790 | map_size=$(shell cat System.map | \ | ||
791 | awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end = $$1} END {if (start != "" && end != "") print strtonum("0x" end) - strtonum("0x" start)}'); \ | ||
792 | if [ "" != "$$map_size" ]; then \ | ||
793 | if test $$map_size -ne $$file_size; then \ | ||
794 | echo "System.map shows a binary size of $$map_size" >&2 ; \ | ||
795 | echo " but u-boot.bin shows $$file_size" >&2 ; \ | ||
796 | exit 1; \ | ||
797 | fi \ | ||
798 | fi | ||
799 | |||
788 | u-boot.bin: u-boot FORCE | 800 | u-boot.bin: u-boot FORCE |
789 | $(call if_changed,objcopy) | 801 | $(call if_changed,objcopy) |
790 | $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE)) | 802 | $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE)) |