1# SPDX-License-Identifier: Apache-2.0 2 3# See root CMakeLists.txt for description and expectations of these macros 4 5macro(toolchain_ld_relocation) 6 set(MEM_RELOCATION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld") 7 set(MEM_RELOCATION_SRAM_DATA_LD 8 "${PROJECT_BINARY_DIR}/include/generated/linker_sram_data_relocate.ld") 9 set(MEM_RELOCATION_SRAM_BSS_LD 10 "${PROJECT_BINARY_DIR}/include/generated/linker_sram_bss_relocate.ld") 11 set(MEM_RELOCATION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c") 12 set(MEM_REGION_DEFAULT_RAM RAM) 13 set(DICT_FILE "${PROJECT_BINARY_DIR}/relocation_dict.txt") 14 15 file(GENERATE 16 OUTPUT 17 ${DICT_FILE} 18 CONTENT 19 $<TARGET_PROPERTY:code_data_relocation_target,COMPILE_DEFINITIONS> 20 ) 21 22 add_custom_command( 23 OUTPUT ${MEM_RELOCATION_CODE} ${MEM_RELOCATION_LD} 24 COMMAND 25 ${PYTHON_EXECUTABLE} 26 ${ZEPHYR_BASE}/scripts/build/gen_relocate_app.py 27 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> 28 -d ${APPLICATION_BINARY_DIR} 29 -i ${DICT_FILE} 30 -o ${MEM_RELOCATION_LD} 31 -s ${MEM_RELOCATION_SRAM_DATA_LD} 32 -b ${MEM_RELOCATION_SRAM_BSS_LD} 33 -c ${MEM_RELOCATION_CODE} 34 --default_ram_region ${MEM_REGION_DEFAULT_RAM} 35 DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY} 36 ) 37 38 add_library(code_relocation_source_lib STATIC ${MEM_RELOCATION_CODE}) 39 target_include_directories(code_relocation_source_lib PRIVATE 40 ${ZEPHYR_BASE}/kernel/include ${ARCH_DIR}/${ARCH}/include) 41 target_link_libraries(code_relocation_source_lib zephyr_interface) 42endmacro() 43