1# SPDX-License-Identifier: Apache-2.0
2
3# '-mcmse' enables the generation of code for the Secure state of the ARMv8-M
4# Security Extensions. This option is required when building a Secure firmware.
5
6zephyr_compile_options_ifdef(CONFIG_ARM_SECURE_FIRMWARE $<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,cmse>>)
7zephyr_compile_options_ifdef(CONFIG_ARM_SECURE_FIRMWARE $<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler,cmse>>)
8zephyr_compile_options_ifdef(CONFIG_ARM_SECURE_FIRMWARE $<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:asm,cmse>>)
9
10if(CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS)
11
12  # --out-implib and --cmse-implib instruct the linker to produce
13  # an import library that consists of a relocatable file containing
14  # only a symbol table with the entry veneers. The library may be used
15  # when building a Non-Secure image which shall have access to Secure
16  # Entry functions.
17  zephyr_ld_options(
18    ${LINKERFLAGPREFIX},--out-implib=${CMAKE_BINARY_DIR}/${CONFIG_ARM_ENTRY_VENEERS_LIB_NAME}
19  )
20
21  zephyr_ld_options(
22    ${LINKERFLAGPREFIX},--cmse-implib
23  )
24
25  # Indicate that the entry veneers library file is created during linking of this firmware.
26  set_property(
27    GLOBAL APPEND PROPERTY
28    extra_post_build_byproducts
29    ${CMAKE_BINARY_DIR}/${CONFIG_ARM_ENTRY_VENEERS_LIB_NAME}
30    )
31
32  zephyr_linker_sources(SECTIONS SORT_KEY z_end secure_entry_functions.ld)
33endif()
34
35# Link the entry veneers library file with the Non-Secure Firmware that needs it.
36zephyr_link_libraries_ifdef(CONFIG_ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS
37  ${CMAKE_BINARY_DIR}/${CONFIG_ARM_ENTRY_VENEERS_LIB_NAME}
38  )
39