Build: Add LLVM toolchain support for an521 only.
Support for other platforms will follow.
Signed-off-by: Anton Komlev <anton.komlev@arm.com>
Change-Id: Id036ecd78bf8e8909af30f78b2bfe5262b78c6b9
diff --git a/secure_fw/partitions/lib/runtime/crt_start.c b/secure_fw/partitions/lib/runtime/crt_start.c
new file mode 100644
index 0000000..5833072
--- /dev/null
+++ b/secure_fw/partitions/lib/runtime/crt_start.c
@@ -0,0 +1,52 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
+ */
+
+#include "utilities.h"
+
+#if defined(__clang_major__) && defined(__GNUC__)
+
+/*
+ * We can not use CMSIS support for LLVM toolchain because it's incompatible
+ * with it. That's why we manunally implement the startup routine below.
+ */
+
+typedef struct __copy_table {
+ uint32_t const *src;
+ uint32_t *dest;
+ uint32_t wlen;
+} __copy_table_t;
+
+typedef struct __zero_table {
+ uint32_t *dest;
+ uint32_t wlen;
+} __zero_table_t;
+
+extern const __copy_table_t __copy_table_start__;
+extern const __copy_table_t __copy_table_end__;
+extern const __zero_table_t __zero_table_start__;
+extern const __zero_table_t __zero_table_end__;
+
+extern int main(int argc, char **argv);
+
+void _start(void)
+{
+ for (__copy_table_t const *pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) {
+ for (uint32_t i = 0u; i < pTable->wlen; ++i) {
+ pTable->dest[i] = pTable->src[i];
+ }
+ }
+
+ for (__zero_table_t const *pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) {
+ for (uint32_t i = 0u; i < pTable->wlen; ++i) {
+ pTable->dest[i] = 0u;
+ }
+ }
+ main(0, NULL);
+ while (1)
+ ;
+}
+#else
+#error This startup file shall be used in LLVM toolchain only.
+#endif