Skip to content

Commit 28b1169

Browse files
fkjagodzinskimaciejbocianski
authored andcommitted
NUVOTON: Fix undefined reference to Reset_Handler_Cascade
Add a "used" attribute to Reset_Handler_Cascade to fix GCC build with the "-flto" flag. This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced.
1 parent 8fcb00c commit 28b1169

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

targets/TARGET_NUVOTON/TARGET_M480/device/startup_M480.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
#if defined(__CC_ARM)
2525
#define WEAK __attribute__ ((weak))
2626
#define ALIAS(f) __attribute__ ((weak, alias(#f)))
27+
#define USED __attribute__ ((used))
2728

2829
#define WEAK_ALIAS_FUNC(FUN, FUN_ALIAS) \
2930
void FUN(void) __attribute__ ((weak, alias(#FUN_ALIAS)));
3031

3132
#elif defined(__ICCARM__)
33+
#define USED __root
3234
//#define STRINGIFY(x) #x
3335
//#define _STRINGIFY(x) STRINGIFY(x)
3436
#define WEAK_ALIAS_FUNC(FUN, FUN_ALIAS) \
@@ -42,6 +44,7 @@ _Pragma(_STRINGIFY(_WEAK_ALIAS_FUNC(FUN, FUN_ALIAS)))
4244
#elif defined(__GNUC__)
4345
#define WEAK __attribute__ ((weak))
4446
#define ALIAS(f) __attribute__ ((weak, alias(#f)))
47+
#define USED __attribute__ ((used))
4548

4649
#define WEAK_ALIAS_FUNC(FUN, FUN_ALIAS) \
4750
void FUN(void) __attribute__ ((weak, alias(#FUN_ALIAS)));
@@ -77,7 +80,7 @@ void Default_Handler(void);
7780
void Reset_Handler(void);
7881
void Reset_Handler_1(void);
7982
void Reset_Handler_2(void);
80-
void Reset_Handler_Cascade(void *sp, void *pc);
83+
USED void Reset_Handler_Cascade(void *sp, void *pc);
8184

8285
/* Cortex-M4 core handlers */
8386
WEAK_ALIAS_FUNC(NMI_Handler, Default_Handler)

0 commit comments

Comments
 (0)