diff options
authorHans de Goede <>2015-09-13 14:45:15 +0200
committerHans de Goede <>2015-10-20 18:40:27 +0200
commit1eb0c03c2198a7ec9de456b83dacdc4831b96cbf (patch)
parent8656c4f76f012254a1a01d6d7956d85d7d3d73bf (diff)
malloc_simple: Add Kconfig option for using only malloc_simple in the SPL
common/dlmalloc.c is quite big, both in .text and .data usage, therefor on some boards the SPL is build to use only malloc_simple.c and not the dlmalloc.c code. This is done in various include/configs/foo.h with the following construct: #ifdef CONFIG_SPL_BUILD #define CONFIG_SYS_MALLOC_SIMPLE #endif This commit introduces a SPL_MALLOC_SIMPLE Kconfig bool which allows selecting this functionality through Kconfig instead. Signed-off-by: Hans de Goede <> Acked-by: Simon Glass <>
5 files changed, 14 insertions, 4 deletions
diff --git a/Kconfig b/Kconfig
index f364a7a4d5..b4ad610f61 100644
--- a/Kconfig
+++ b/Kconfig
@@ -114,6 +114,16 @@ config SPL
If you want to build SPL as well as the normal image, say Y.
+ bool
+ depends on SPL
+ prompt "Only use malloc_simple functions in the spl"
+ help
+ Say Y here to only use the *_simple malloc functions from
+ malloc_simple.c, rather then using the versions from dlmalloc.c
+ this will make the SPL binary smaller at the cost of more heap
+ usage as the *_simple malloc functions do not re-use free-ed mem.
config SPL_STACK_R
depends on SPL
bool "Enable SDRAM location for SPL stack"
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index c74586376d..9bf1fedd51 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -40,7 +40,7 @@ void *memalign_simple(size_t align, size_t bytes)
return ptr;
void *calloc(size_t nmemb, size_t elem_size)
size_t size = nmemb * elem_size;
diff --git a/include/_exports.h b/include/_exports.h
index 74a882a680..11beeb24f1 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -23,7 +23,7 @@
EXPORT_FUNC(dummy, void, free_hdlr, void)
EXPORT_FUNC(malloc, void *, malloc, size_t)
EXPORT_FUNC(free, void, free, void *)
EXPORT_FUNC(udelay, void, udelay, unsigned long)
diff --git a/include/exports.h b/include/exports.h
index a3e0469d40..deef8fbec8 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -19,7 +19,7 @@ int printf(const char* fmt, ...);
void install_hdlr(int, interrupt_handler_t, void*);
void free_hdlr(int);
void *malloc(size_t);
void free(void*);
void __udelay(unsigned long);
diff --git a/include/malloc.h b/include/malloc.h
index f4da9e6ddd..f20e4d3d2a 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -872,7 +872,7 @@ extern Void_t* sbrk();
#define malloc malloc_simple
#define realloc realloc_simple
#define memalign memalign_simple
OpenPOWER on IntegriCloud