aboutsummaryrefslogtreecommitdiff
path: root/ta
diff options
context:
space:
mode:
authorJerome Forissier <jerome.forissier@linaro.org>2018-02-21 10:00:49 +0100
committerJérôme Forissier <jerome.forissier@linaro.org>2018-02-21 17:21:14 +0100
commit8c8e144172ed2205d752ec0f5103d3e172e860eb (patch)
tree9865c0c6746b58c4641ff33e3fe93bd5a8d39f51 /ta
parent0c5bedb538f2012dda85c1a3ec4ccfb76b64a4f0 (diff)
ta_dev_kit.mk: define ENABLE_MDBG when CFG_TEE_TA_MALLOC_DEBUG is set
In order to use the memory leak detection code, a user-mode TA needs two things: - A version of libutils.a that was built with malloc debug code. This is taken care of by ta/ta.mk which sets ENABLE_MDBG=1 when CFG_TEE_TA_MALLOC_DEBUG is 'y'. - The proper declarations for mdbg_malloc(), mdbg_free(), mdbg_check() etc. as well as the macro redefinitions for malloc(), free() etc. in the header files when the TA is built. This patch adds the missing definition of ENABLE_MDBG in ta/mk/ta_dev_kit.mk when CFG_TEE_TA_MALLOC_DEBUG is 'y'. In addition, the usage of CFG_TEE_TA_MALLOC_DEBUG and CFG_TEE_CORE_MALLOC_DEBUG is better documented in mk/conf.mk. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Diffstat (limited to 'ta')
-rw-r--r--ta/mk/ta_dev_kit.mk7
-rw-r--r--ta/ta.mk2
2 files changed, 9 insertions, 0 deletions
diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk
index a717bbdf..c7506dbb 100644
--- a/ta/mk/ta_dev_kit.mk
+++ b/ta/mk/ta_dev_kit.mk
@@ -53,6 +53,13 @@ cflags$(sm) := $($(sm)-platform-cflags) $(CFLAGS_$(sm))
CFG_TEE_TA_LOG_LEVEL ?= 2
cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
+ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
+# TAs will automatically use debug versions of the malloc() functions
+# in libutils (malloc() will be re-defined as mdbg_malloc() etc.).
+# mdbg_check() will also be visible.
+cppflags$(sm) += -DENABLE_MDBG=1
+endif
+
cppflags$(sm) += -I. -I$(ta-dev-kit-dir)/include
libdirs += $(ta-dev-kit-dir)/lib
diff --git a/ta/ta.mk b/ta/ta.mk
index 57c4fe7a..7f42123b 100644
--- a/ta/ta.mk
+++ b/ta/ta.mk
@@ -19,6 +19,8 @@ cppflags$(sm) += -include $(conf-file)
# Config flags from mk/config.mk
cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
+# Build malloc debug code into libutils: (mdbg_malloc(), mdbg_free(),
+# mdbg_check(), etc.).
cppflags$(sm) += -DENABLE_MDBG=1
endif