platform: nordic_nrf: ifdef out weak fault handlers

Default IRQ handlers will usually be overriden as they are weak. But
due to the way TF-M links it's binary (doesn't use whole-archive),
weak doesn't always work. So we explicitly ifdef out some IRQ handlers
that we know will be overridden by non-weak symbols anyway to be safe.

Change-Id: Ifd3a67ac2276fa8d7ceec29582f8cec02b7cac54
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
diff --git a/platform/ext/target/nordic_nrf/common/core/startup.h b/platform/ext/target/nordic_nrf/common/core/startup.h
index 239e37f..7d4fd6a 100644
--- a/platform/ext/target/nordic_nrf/common/core/startup.h
+++ b/platform/ext/target/nordic_nrf/common/core/startup.h
@@ -27,6 +27,11 @@
 __NO_RETURN void __attribute__((weak, alias("default_tfm_IRQHandler"))) handler_name(void);
 
 __NO_RETURN void Reset_Handler(void);
+__NO_RETURN void HardFault_Handler(void);
+__NO_RETURN void MemManage_Handler(void);
+__NO_RETURN void BusFault_Handler(void);
+__NO_RETURN void UsageFault_Handler(void);
+__NO_RETURN void SecureFault_Handler(void);
 
 void SPU_IRQHandler(void);
 
diff --git a/platform/ext/target/nordic_nrf/common/nrf5340/gcc/startup_nrf5340.c b/platform/ext/target/nordic_nrf/common/nrf5340/gcc/startup_nrf5340.c
index a8062e3..669dcb7 100644
--- a/platform/ext/target/nordic_nrf/common/nrf5340/gcc/startup_nrf5340.c
+++ b/platform/ext/target/nordic_nrf/common/nrf5340/gcc/startup_nrf5340.c
@@ -39,11 +39,6 @@
 }
 
 DEFAULT_IRQ_HANDLER(NMI_Handler)
-DEFAULT_IRQ_HANDLER(HardFault_Handler)
-DEFAULT_IRQ_HANDLER(MemManage_Handler)
-DEFAULT_IRQ_HANDLER(BusFault_Handler)
-DEFAULT_IRQ_HANDLER(UsageFault_Handler)
-DEFAULT_IRQ_HANDLER(SecureFault_Handler)
 DEFAULT_IRQ_HANDLER(SVC_Handler)
 DEFAULT_IRQ_HANDLER(DebugMon_Handler)
 DEFAULT_IRQ_HANDLER(PendSV_Handler)
@@ -92,6 +87,19 @@
 
 #if defined(DOMAIN_NS) || defined(BL2)
 DEFAULT_IRQ_HANDLER(SPU_IRQHandler)
+DEFAULT_IRQ_HANDLER(HardFault_Handler)
+DEFAULT_IRQ_HANDLER(MemManage_Handler)
+DEFAULT_IRQ_HANDLER(BusFault_Handler)
+DEFAULT_IRQ_HANDLER(UsageFault_Handler)
+DEFAULT_IRQ_HANDLER(SecureFault_Handler)
+#else
+/*
+ * Default IRQ handlers will usually be overriden as they are
+ * weak. But due to the way TF-M links it's binary (doesn't use
+ * whole-archive), weak doesn't always work. So we explicitly ifdef
+ * out some IRQ handlers that we know will be overridden anyway to be
+ * safe.
+ */
 #endif
 
 #if defined ( __GNUC__ )
diff --git a/platform/ext/target/nordic_nrf/common/nrf91/gcc/startup_nrf91.c b/platform/ext/target/nordic_nrf/common/nrf91/gcc/startup_nrf91.c
index 5575654..efa7111 100644
--- a/platform/ext/target/nordic_nrf/common/nrf91/gcc/startup_nrf91.c
+++ b/platform/ext/target/nordic_nrf/common/nrf91/gcc/startup_nrf91.c
@@ -36,11 +36,6 @@
 }
 
 DEFAULT_IRQ_HANDLER(NMI_Handler)
-DEFAULT_IRQ_HANDLER(HardFault_Handler)
-DEFAULT_IRQ_HANDLER(MemManage_Handler)
-DEFAULT_IRQ_HANDLER(BusFault_Handler)
-DEFAULT_IRQ_HANDLER(UsageFault_Handler)
-DEFAULT_IRQ_HANDLER(SecureFault_Handler)
 DEFAULT_IRQ_HANDLER(SVC_Handler)
 DEFAULT_IRQ_HANDLER(DebugMon_Handler)
 DEFAULT_IRQ_HANDLER(PendSV_Handler)
@@ -79,6 +74,19 @@
 
 #if defined(DOMAIN_NS) || defined(BL2)
 DEFAULT_IRQ_HANDLER(SPU_IRQHandler)
+DEFAULT_IRQ_HANDLER(HardFault_Handler)
+DEFAULT_IRQ_HANDLER(MemManage_Handler)
+DEFAULT_IRQ_HANDLER(BusFault_Handler)
+DEFAULT_IRQ_HANDLER(UsageFault_Handler)
+DEFAULT_IRQ_HANDLER(SecureFault_Handler)
+#else
+/*
+ * Default IRQ handlers will usually be overriden as they are
+ * weak. But due to the way TF-M links it's binary (doesn't use
+ * whole-archive), weak doesn't always work. So we explicitly ifdef
+ * out some IRQ handlers that we know will be overridden anyway to be
+ * safe.
+ */
 #endif
 
 #if defined ( __GNUC__ )