CMake: Add a function to generate executable artifacts with memap (#13695)

- Add linker option to generate map file for GCC_ARM and ARM toolchain
- Add mbed_generate_map_file function to call memap.py (parse the map
file).
- Add mbed_generate_executable function to generate executable artifacts with a memory map table
pull/13566/head
Rajkumar Kanagaraj 2020-10-08 18:39:13 +01:00 committed by Hugues Kamba
parent 22dd57b35b
commit d84baa8fa1
3 changed files with 28 additions and 0 deletions

View File

@ -167,3 +167,28 @@ function(mbed_generate_bin_hex target)
VERBATIM
)
endfunction()
#
# Parse toolchain generated map file of `target` and display a readable table format.
#
function(mbed_generate_map_file target)
find_package (Python3)
add_custom_command(
TARGET
${target}
POST_BUILD
COMMAND ${Python3_EXECUTABLE} ${MBED_ROOT}/tools/memap.py -t ${MBED_TOOLCHAIN} -d 4 ${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}
COMMENT
"Displaying memory map for ${target}"
)
endfunction()
#
# Generate executables
#
function(mbed_generate_executable target)
mbed_generate_bin_hex(${target})
mbed_generate_map_file(${target})
endfunction()

View File

@ -55,6 +55,7 @@ function(mbed_set_toolchain_options target)
list(APPEND link_options
"${MBED_STUDIO_ARM_COMPILER}"
"--map"
)
# Add linking time preprocessor macro for TFM targets

View File

@ -21,6 +21,8 @@ function(mbed_set_toolchain_options target)
"-Wl,--end-group"
"-specs=nosys.specs"
"-T" "${CMAKE_BINARY_DIR}/${APP_TARGET}.link_script.ld"
"-Wl,-Map=${CMAKE_BINARY_DIR}/${APP_TARGET}.map"
"-Wl,--cref"
)
# Add linking time preprocessor macro for TFM targets