Skip to content

Commit

Permalink
[nrf noup] platform: nordic_nrf: Use aliased default IRQ handlers
Browse files Browse the repository at this point in the history
Currently we are generating dozens of default IRQ Handlers that each
just spin. In sum, 256 bytes of IRQ handlers that do nothing.

In this patch we save these bytes by using the alias attribute.

Now there is only one default IRQ handler placed in flash and all the
default IRQ handlers alias to it.

I tried to place the duplicated default_tfm_IRQHandler in the common
startup.c, but it did not work. I am not certain, but I think this is
due to a problem with the way we link in TF-M.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
  • Loading branch information
SebastianBoe authored and nordicjm committed Jul 13, 2023
1 parent cca1de1 commit 3dcb0c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions platform/ext/target/nordic_nrf/common/core/startup.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ typedef void(*VECTOR_TABLE_Type)(void);
void __PROGRAM_START(void) __NO_RETURN;

#define DEFAULT_IRQ_HANDLER(handler_name) \
void __WEAK handler_name(void) __NO_RETURN; \
void handler_name(void) { \
while(1); \
}
__NO_RETURN void __attribute__((weak, alias("default_tfm_IRQHandler"))) handler_name(void);

__NO_RETURN void Reset_Handler(void);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "hw_init.h"
#include "startup.h"

__NO_RETURN __attribute__((naked)) void default_tfm_IRQHandler(void) {
while(1);
}

DEFAULT_IRQ_HANDLER(NMI_Handler)
DEFAULT_IRQ_HANDLER(HardFault_Handler)
DEFAULT_IRQ_HANDLER(MemManage_Handler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "hw_init.h"
#include "startup.h"

__NO_RETURN __attribute__((naked)) void default_tfm_IRQHandler(void) {
while(1);
}

DEFAULT_IRQ_HANDLER(NMI_Handler)
DEFAULT_IRQ_HANDLER(HardFault_Handler)
DEFAULT_IRQ_HANDLER(MemManage_Handler)
Expand Down

0 comments on commit 3dcb0c3

Please sign in to comment.