[PATCH 1/2] add CONFIG_BAREBOX_MAX_SIZE to check if the size of barebox exceed the target size

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sun Jan 15 04:38:15 EST 2012


this will allow to detected silent oversize result

if 0x0 the size will not been checked

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 Makefile       |    8 ++++++++
 common/Kconfig |    8 ++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index d8e685e..eeb5b5d 100644
--- a/Makefile
+++ b/Makefile
@@ -659,6 +659,14 @@ OBJCOPYFLAGS_barebox.bin = -O binary
 
 barebox.bin: barebox FORCE
 	$(call if_changed,objcopy)
+	size=`stat -c%s $@`; \
+	max_size=`printf "%d" $(CONFIG_BAREBOX_MAX_SIZE)`; \
+	if [ $$max_size -lt $$size -a \
+	     $$max_size -ne 0 ] ; \
+	then \
+		echo "$@ size $$size > of the maximum size $$max_size"; \
+		exit 1 ; \
+	fi
 
 ifdef CONFIG_X86
 barebox.S: barebox
diff --git a/common/Kconfig b/common/Kconfig
index 382e591..a034686 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -104,6 +104,14 @@ config TEXT_BASE
 	help
 	  The Address barebox gets linked at.
 
+config BAREBOX_MAX_SIZE
+	prompt "Maximum size of barebox"
+	hex
+	default 0x0
+	help
+	  Define the maximum size of barebox
+	  If 0x0 the size will not been check
+
 config HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	bool
 
-- 
1.7.7




More information about the barebox mailing list