Skip to content

Commit d993c5a

Browse files
committed
NUVOTON: Re-implement __PC() with toolchain built-in
Re-implement __PC() by replacing BSP assembly with toolchain built-in.
1 parent 3548d38 commit d993c5a

File tree

3 files changed

+32
-37
lines changed

3 files changed

+32
-37
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/device/M2351_funcs.S

Lines changed: 0 additions & 37 deletions
This file was deleted.

targets/TARGET_NUVOTON/TARGET_M2351/device/system_M2351.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,19 @@ void AssertError(uint8_t * file, uint32_t line)
115115
}
116116
#endif
117117

118+
/* Return LR (return address)
119+
*
120+
* Replace BSP assembly implementation with toolchain built-in (borrow MBED_CALLER_ADDR())
121+
*/
122+
uint32_t __PC(void)
123+
{
124+
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
125+
return (uint32_t) __builtin_extract_return_addr(__builtin_return_address(0));
126+
#elif defined(__CC_ARM)
127+
return (uint32_t) __builtin_return_address(0);
128+
#elif defined(__ICCARM__)
129+
return (uint32_t) __get_LR();
130+
#else
131+
#error("__PC() not implemented")
132+
#endif
133+
}

targets/TARGET_NUVOTON/TARGET_M261/device/system_M261.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,19 @@ void AssertError(uint8_t * file, uint32_t line)
116116
}
117117
#endif
118118

119+
/* Return LR (return address)
120+
*
121+
* Replace BSP assembly implementation with toolchain built-in (borrow MBED_CALLER_ADDR())
122+
*/
123+
uint32_t __PC(void)
124+
{
125+
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
126+
return (uint32_t) __builtin_extract_return_addr(__builtin_return_address(0));
127+
#elif defined(__CC_ARM)
128+
return (uint32_t) __builtin_return_address(0);
129+
#elif defined(__ICCARM__)
130+
return (uint32_t) __get_LR();
131+
#else
132+
#error("__PC() not implemented")
133+
#endif
134+
}

0 commit comments

Comments
 (0)