2019-05-03 16:33:03 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
# See root CMakeLists.txt for description and expectations of these macros
|
|
|
|
|
|
|
|
macro(toolchain_ld_relocation)
|
2019-07-02 01:23:38 +08:00
|
|
|
set(MEM_RELOCATION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
|
|
|
|
set(MEM_RELOCATION_SRAM_DATA_LD
|
2019-05-14 00:30:52 +08:00
|
|
|
"${PROJECT_BINARY_DIR}/include/generated/linker_sram_data_relocate.ld")
|
2019-07-02 01:23:38 +08:00
|
|
|
set(MEM_RELOCATION_SRAM_BSS_LD
|
2019-05-14 00:30:52 +08:00
|
|
|
"${PROJECT_BINARY_DIR}/include/generated/linker_sram_bss_relocate.ld")
|
2019-07-02 01:23:38 +08:00
|
|
|
set(MEM_RELOCATION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c")
|
2019-05-03 16:33:03 +08:00
|
|
|
|
|
|
|
add_custom_command(
|
2019-07-02 01:23:38 +08:00
|
|
|
OUTPUT ${MEM_RELOCATION_CODE} ${MEM_RELOCATION_LD}
|
2019-05-03 16:33:03 +08:00
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE}
|
|
|
|
${ZEPHYR_BASE}/scripts/gen_relocate_app.py
|
|
|
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
|
|
|
-d ${APPLICATION_BINARY_DIR}
|
|
|
|
-i '$<TARGET_PROPERTY:code_data_relocation_target,COMPILE_DEFINITIONS>'
|
2019-07-02 01:23:38 +08:00
|
|
|
-o ${MEM_RELOCATION_LD}
|
|
|
|
-s ${MEM_RELOCATION_SRAM_DATA_LD}
|
|
|
|
-b ${MEM_RELOCATION_SRAM_BSS_LD}
|
|
|
|
-c ${MEM_RELOCATION_CODE}
|
2019-05-03 16:33:03 +08:00
|
|
|
DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY}
|
|
|
|
)
|
|
|
|
|
2019-07-02 01:23:38 +08:00
|
|
|
add_library(code_relocation_source_lib STATIC ${MEM_RELOCATION_CODE})
|
2019-05-03 16:33:03 +08:00
|
|
|
target_link_libraries(code_relocation_source_lib zephyr_interface)
|
|
|
|
endmacro()
|