lmdk: Remove content of the .module section from final module image

The .module section contains the module manifest read by rimage. It should
not be included in the final loadable module image. Flags of this section
are now modified using objcopy to ignore it by rimage.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
This commit is contained in:
Adrian Warecki 2023-10-26 16:51:11 +02:00 committed by Kai Vehmanen
parent d0931d3af5
commit 0c2069c2c3
2 changed files with 17 additions and 6 deletions

View File

@ -13,8 +13,6 @@ foreach(MODULE ${MODULES_LIST})
add_executable(${MODULE})
add_subdirectory(${LMDK_BASE}/modules/${MODULE} ${MODULE}_module)
### set_target_properties(${MODULE} PROPERTIES OUTPUT_NAME ${MODULE}.mod)
# uncomment line below to compile module with debug information
#target_compile_options(${MODULE} PUBLIC "-g3")
@ -58,13 +56,26 @@ cmake_path(APPEND SOF_BASE "../build-rimage" OUTPUT_VARIABLE RIMAGE_SOF_INSTALL_
cmake_path(NORMAL_PATH RIMAGE_SOF_INSTALL_DIR)
cmake_path(ABSOLUTE_PATH SIGNING_KEY BASE_DIRECTORY ${CMAKE_SOURCE_DIR} NORMALIZE)
foreach(MOD_NAME IN LISTS MODULES_LIST)
list(APPEND RIMAGE_MODULES_LIST ${MOD_NAME}.mod)
# Change .module section flags to tell rimage to not include it in a final image
add_custom_target(${MOD_NAME}.mod
COMMENT "Preparing .mod(ule) files for rimage"
DEPENDS ${MOD_NAME}
COMMAND ${CMAKE_OBJCOPY}
--set-section-flags .module=noload,readonly
${MOD_NAME} ${MOD_NAME}.mod
)
endforeach()
find_program(RIMAGE_COMMAND NAMES rimage
PATHS "${RIMAGE_INSTALL_DIR}"
HINTS "${RIMAGE_SOF_INSTALL_DIR}"
REQUIRED)
add_custom_target(${PROJECT_NAME}_target ALL
DEPENDS ${MODULES_LIST}
COMMAND ${RIMAGE_COMMAND} -k ${SIGNING_KEY} -f 2.0.0 -b 1 -o ${RIMAGE_OUTPUT_FILE} -c ${TOML} -e ${MODULES_LIST}
DEPENDS ${RIMAGE_MODULES_LIST}
COMMAND ${RIMAGE_COMMAND} -k ${SIGNING_KEY} -f 2.0.0 -b 1 -o ${RIMAGE_OUTPUT_FILE} -c ${TOML} -e ${RIMAGE_MODULES_LIST}
COMMAND ${CMAKE_COMMAND} -E cat ${RIMAGE_OUTPUT_FILE}.xman ${RIMAGE_OUTPUT_FILE} > ${OUTPUT_FILE}
)

View File

@ -25,7 +25,7 @@ SECTIONS {
} >HPSRAM_seg : rodata_phdr
/* Module manifest is here */
.module : ALIGN(4096) {
.module 0 : {
KEEP(*(.module))
} >HPSRAM_seg : rodata_phdr
}
}