cmake: Toolchain abstraction: Introduce toolchain_ld_relocation macro
No functional change expected. This is motivated by the wish to abstract Zephyr's usage of toolchains, permitting non-intrusive porting to other (commercial) toolchains. Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
This commit is contained in:
parent
87d1f0682b
commit
86a3e8ff40
3 changed files with 27 additions and 19 deletions
|
@ -750,25 +750,8 @@ if(CONFIG_GEN_ISR_TABLES)
|
|||
endif()
|
||||
|
||||
if(CONFIG_CODE_DATA_RELOCATION)
|
||||
set(MEM_RELOCATAION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
|
||||
set(MEM_RELOCATAION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MEM_RELOCATAION_CODE} ${MEM_RELOCATAION_LD}
|
||||
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>'
|
||||
-o ${MEM_RELOCATAION_LD}
|
||||
-c ${MEM_RELOCATAION_CODE}
|
||||
DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY}
|
||||
)
|
||||
|
||||
add_library(code_relocation_source_lib STATIC ${MEM_RELOCATAION_CODE})
|
||||
target_link_libraries(code_relocation_source_lib zephyr_interface)
|
||||
|
||||
# @Intent: Linker script to relocate .text, data and .bss sections
|
||||
toolchain_ld_relocation()
|
||||
endif()
|
||||
|
||||
if(CONFIG_USERSPACE)
|
||||
|
|
|
@ -57,3 +57,4 @@ endmacro()
|
|||
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_base.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_baremetal.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_cpp.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_relocation.cmake)
|
||||
|
|
24
cmake/linker/ld/target_relocation.cmake
Normal file
24
cmake/linker/ld/target_relocation.cmake
Normal file
|
@ -0,0 +1,24 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# See root CMakeLists.txt for description and expectations of these macros
|
||||
|
||||
macro(toolchain_ld_relocation)
|
||||
set(MEM_RELOCATAION_LD "${PROJECT_BINARY_DIR}/include/generated/linker_relocate.ld")
|
||||
set(MEM_RELOCATAION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MEM_RELOCATAION_CODE} ${MEM_RELOCATAION_LD}
|
||||
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>'
|
||||
-o ${MEM_RELOCATAION_LD}
|
||||
-c ${MEM_RELOCATAION_CODE}
|
||||
DEPENDS app kernel ${ZEPHYR_LIBS_PROPERTY}
|
||||
)
|
||||
|
||||
add_library(code_relocation_source_lib STATIC ${MEM_RELOCATAION_CODE})
|
||||
target_link_libraries(code_relocation_source_lib zephyr_interface)
|
||||
endmacro()
|
Loading…
Add table
Add a link
Reference in a new issue