summaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-01-18 02:07:33 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-01-23 09:43:28 +0100
commit463229490e5624f55a968d9321334f441a981ef2 (patch)
treeb42df7c0d72a08efcaca576b2ab7c542c6f300db /include/asm-generic
parent4bcf52aa6635cac1b88c513f90f732595979cf94 (diff)
downloadbarebox-463229490e5624f55a968d9321334f441a981ef2.tar.gz
barebox-463229490e5624f55a968d9321334f441a981ef2.tar.xz
introduce barebox_bare_init_size to known the bare_init size and check it
this allow to check we do not exceed the size of the SRAM as example introduce BAREBOX_MAX_BARE_INIT_SIZE the maximum size of bare_init this will allow your bare_init will fit in SRAM as example ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/barebox.lds.h15
-rw-r--r--include/asm-generic/sections.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index 5467d3a8a0..3c0be96787 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -26,3 +26,18 @@
#define BAREBOX_SYMS KEEP(*(__usymtab))
#define BAREBOX_MAGICVARS KEEP(*(SORT_BY_NAME(.barebox_magicvar*)))
+
+#if defined(CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE) && \
+CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
+#define MAX_BARE_INIT_SIZE CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE
+#else
+#define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
+#endif
+
+#include <linux/stringify.h>
+/* use 2 ASSERT because ld can not accept '"size" "10"' format */
+#define BAREBOX_BARE_INIT_SIZE \
+ _barebox_bare_init_size = __bare_init_end - _text; \
+ ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
+ ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
+
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 1f48fb8c6b..5484b6f004 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -3,9 +3,12 @@
extern char _text[], _stext[], _etext[];
extern char __bss_start[], __bss_stop[];
+extern char __bare_init_start[], __bare_init_end[];
extern char _end[];
extern void *_barebox_image_size;
+extern void *_barebox_bare_init_size;
#define barebox_image_size (unsigned int)&_barebox_image_size
+#define barebox_bare_init_size (unsigned int)&_barebox_bare_init_size
#endif /* _ASM_GENERIC_SECTIONS_H_ */