Build: IAR support
- This patch contains IAR specific changes to a few source files,
mostly #pragmas to allow calling external functions from inline.
- Startup code and linker scripts
- cmake files
- cmsis file for the IAR compiler
Other targets are added in later commits
There are still lots of warnings generated for non-standard C, which
I plan to address in later updates
- Cleaned out some dead definitions in the common linker script in
preparation for psoc64 integration.
- Made sure that .rodata from tfm_its_secure_api.o is placed in
TFM_UNPRIV_CODE, which otherwised caused a memory management fault
in test TFM_ITS_TEST_2023 when compiled without optimization.
- Added dummy initializers to tfm_secure_irq_handlers.inc.template to
avoid illegal empty arrays.
- Reworked the iovec_args_t struct handling in tfm_func_api.c, which
was causing runtime errors when compiled with optimization.
According to the compiler developers the old implemetation is
illegal, you are not allowed to use the address of a scalar as an
address outside of that scalar.
- Added conditional around ".syntax unified" in tfm_nspm_ipc.c.
- Added "template" attribute for the IAR linker script in
tfm_generated_file_list.yaml.
- Cleaned up some indentation and tab/space issues
Change-Id: I8599d461f62194bc734e472a28d7111ba3b5046a
Signed-off-by: TTornblom <thomas.tornblom@iar.com>
diff --git a/cmake/Compiler/IARARM.cmake b/cmake/Compiler/IARARM.cmake
new file mode 100644
index 0000000..5bb2a37
--- /dev/null
+++ b/cmake/Compiler/IARARM.cmake
@@ -0,0 +1,55 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+if(_IARARM_CMAKE_LOADED_TFM)
+ return()
+endif()
+set(_IARARM_CMAKE_LOADED_TFM TRUE)
+
+get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
+get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
+
+set(CMAKE_EXECUTABLE_SUFFIX ".axf")
+
+find_program(CMAKE_IARARM_LINKER ilinkarm HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+find_program(CMAKE_IARARM_AR iarchive HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+find_program(CMAKE_IARARM_IELFTOOL ielftool HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+
+set(CMAKE_LINKER "${CMAKE_IARARM_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
+mark_as_advanced(CMAKE_IARARM_LINKER)
+set(CMAKE_AR "${CMAKE_IARARM_AR}" CACHE FILEPATH "The IAR archiver" FORCE)
+mark_as_advanced(CMAKE_IARARM_AR)
+
+macro(__compiler_iararm lang)
+ if(NOT CMAKE_${lang}_FLAGS_SET)
+ set(CMAKE_${lang}_FLAGS_SET TRUE)
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
+
+ if (NOT ${lang} STREQUAL "ASM")
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " --debug -On")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ohz -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Ohs -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Ohs --debug")
+ endif()
+
+ set(CMAKE_${lang}_OUTPUT_EXTENSION ".o")
+ set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1)
+ set(CMAKE_STATIC_LIBRARY_PREFIX_${lang} "")
+ set(CMAKE_STATIC_LIBRARY_SUFFIX_${lang} ".a")
+
+ set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
+
+ set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --map <TARGET_BASE>.map")
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> --preprocess=n <PREPROCESSED_SOURCE> <SOURCE> ")
+ set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> <SOURCE> -la <ASSEMBLY_SOURCE>")
+
+ set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ins <DEPFILE>")
+ endif()
+endmacro()