[PATCH 2/9] arm: do not place huge encoder tables on stack when it is too small

Paul Osmialowski
2015-06-23T21:19:40Z

Since stack on Cortex-M3 is too small, we need configuration option
to avoid using it for huge encoder tables of zlib.

Signed-off-by: Paul Osmialowski <pawelo-rhuoMcPwk82rDJvtcaxF/A@public.gmane.org>
---
arch/arm/Kconfig-nommu | 4 ++++
lib/zlib_inflate/inflate.c | 5 +++++
2 files changed, 9 insertions(+)

diff --git a/arch/arm/Kconfig-nommu b/arch/arm/Kconfig-nommu
index aed66d5..965ca97 100644
--- a/arch/arm/Kconfig-nommu
+++ b/arch/arm/Kconfig-nommu
@@ -62,3 +62,7 @@ config ARM_MPU

If your CPU has an MPU then you should choose 'y' here unless you
know that you do not want to use the MPU.
+
+config ZLIB_INFLATE_STACK_SAVING
+ bool 'Do not place huge encoder tables on stack' if ZLIB_INFLATE
+ depends on ZLIB_INFLATE
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index 58a733b..917b7cf 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -75,9 +75,14 @@ int zlib_inflateInit2(z_streamp strm, int windowBits)
Return state with length and distance decoding tables and index sizes set to
fixed code decoding. This returns fixed tables from inffixed.h.
*/
+#ifdef CONFIG_ZLIB_INFLATE_STACK_SAVING
+# include "inffixed.h"
+#endif
static void zlib_fixedtables(struct inflate_state *state)
{
+#ifndef CONFIG_ZLIB_INFLATE_STACK_SAVING
# include "inffixed.h"
+#endif
state->lencode = lenfix;
state->lenbits = 9;
state->distcode = distfix;
--
2.3.6

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html