GCC alias to function outside of translation unit -AKA- is this even the right tool for the job?

喜夏-厌秋 提交于 2019-11-28 11:19:01

You should be able to do this either with a linker script, or by passing the appropriate option to the linker, eg. for ld, --defsym=SVC_Handler=vPortSVCHandler

See the binutils documentation for more information on the ld --defsym option, and assignments in linker scripts

I think the problem with alias is, that it expects a declared and defined function, since it is just an alias. You want to use it as a forward-declaration of another function. I got a similar thing to work like that:

void SVC_Handler(void) asm("vPortSVCHandler");

This renames the entry point of the SVC_Handler, and if you then do not define it, it should find vPortSVCHandler.

See: https://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html

Another solution that I gleaned from one of the FreeRTOS examples is to add the following to your FreeRTOSConfig.h ...

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names - or at least those used in the unmodified vector table. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

The original file is from FreeRTOS/Demo/CORTEX_M0_LPC1114_LPCXpresso/RTOSDemo/Source/FreeRTOSConfig.h which also integrates the CMSIS system clock into the config. A very nice starting point for a CMSIS/FreeRTOS project.

I'm pretty sure SVC handler is only used by FreeRTOS at initial startup, so adding an indirection exception handler isn't going to hurt performance (but its ugly). Best ask this on the FreeRTOS forum, response there is usually great.

Hope this helps, Best Regards, Dave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!