target_relocation.cmake 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # SPDX-License-Identifier: Apache-2.0
  2. # See root CMakeLists.txt for description and expectations of these macros
  3. macro(toolchain_ld_relocation)
  4. set(MEM_RELOCATION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
  5. set(MEM_RELOCATION_SRAM_DATA_LD
  6. "${PROJECT_BINARY_DIR}/include/generated/linker_sram_data_relocate.ld")
  7. set(MEM_RELOCATION_SRAM_BSS_LD
  8. "${PROJECT_BINARY_DIR}/include/generated/linker_sram_bss_relocate.ld")
  9. set(MEM_RELOCATION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c")
  10. add_custom_command(
  11. OUTPUT ${MEM_RELOCATION_CODE} ${MEM_RELOCATION_LD}
  12. COMMAND
  13. ${PYTHON_EXECUTABLE}
  14. ${ZEPHYR_BASE}/scripts/gen_relocate_app.py
  15. $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
  16. -d ${APPLICATION_BINARY_DIR}
  17. -i \"$<TARGET_PROPERTY:code_data_relocation_target,COMPILE_DEFINITIONS>\"
  18. -o ${MEM_RELOCATION_LD}
  19. -s ${MEM_RELOCATION_SRAM_DATA_LD}
  20. -b ${MEM_RELOCATION_SRAM_BSS_LD}
  21. -c ${MEM_RELOCATION_CODE}
  22. DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY}
  23. )
  24. add_library(code_relocation_source_lib STATIC ${MEM_RELOCATION_CODE})
  25. target_link_libraries(code_relocation_source_lib zephyr_interface)
  26. endmacro()