refactor: improve readability of symbol table

Make the symbol table produced by the memory mapping script more
readable. Add a generic interface for interacting with ELF binaries.
This interface enables us to get symbols that provide some insights into
TF-A's memory usage.

Change-Id: I6646f817a1d38d6184b837b78039b7465a533c5c
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
diff --git a/Makefile b/Makefile
index 1a80244..a925300 100644
--- a/Makefile
+++ b/Makefile
@@ -1074,11 +1074,6 @@
 # Variable for use with Python
 PYTHON			?=	python3
 
-# Variables for use with PRINT_MEMORY_MAP
-PRINT_MEMORY_MAP_PATH		?=	tools/memory
-PRINT_MEMORY_MAP		?=	${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
-INVERTED_MEMMAP			?=	0
-
 # Variables for use with documentation build using Sphinx tool
 DOCS_PATH		?=	docs
 
@@ -1139,7 +1134,6 @@
         GICV2_G0_FOR_EL3 \
         HANDLE_EA_EL3_FIRST_NS \
         HW_ASSISTED_COHERENCY \
-        INVERTED_MEMMAP \
         MEASURED_BOOT \
         DRTM_SUPPORT \
         NS_TIMER_SWITCH \
@@ -1653,9 +1647,14 @@
 romlib.bin: libraries FORCE
 	${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
 
-# Call print_memory_map tool
 memmap: all
-	${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
+ifdef UNIX_MK
+	${Q}PYTHONPATH=${CURDIR}/tools/memory \
+		${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
+else
+	${Q}set PYTHONPATH=${CURDIR}/tools/memory && \
+		${PYTHON} -m memory.memmap -sr ${BUILD_PLAT}
+endif
 
 doc:
 	@echo "  BUILD DOCUMENTATION"