GCC别名功能翻译单元-AKA-的外面是这甚至对工作的工具? [英] GCC alias to function outside of translation unit -AKA- is this even the right tool for the job?

查看:838
本文介绍了GCC别名功能翻译单元-AKA-的外面是这甚至对工作的工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与FreeRTOS操作系统上的STM32(Cortex-M3的)工作,并使用CMSIS库从ST到引导一切。

I'm working with FreeRTOS on an STM32 (Cortex-M3), and using the CMSIS library from ST to bootstrap everything.

该CMSIS库定义弱符号 SVC_HANDLER 在启动.S文件。它必须在某个地方为了得到你的ISR在中断向量表覆盖。 FreeRTOS的定义 vPortSVCHandler ,这是我想有处理SVC中断的ISR。

The CMSIS library defines the weak symbol SVC_Handler in the startup ".s" file. It must be overridden somewhere in order to get your ISR in the interrupt vector table. FreeRTOS defines vPortSVCHandler, which is the ISR I want to have handle the SVC interrupt.

我想胶水两个一起用我的应用程序code(即W / O modifyng FreeRTOS操作系统或CMSIS源$ C ​​$ C)。我认为一个别名将是工作的工具,所以我想这(在一个单独的源文件,main.c中):

I would like to "glue" the two together using my application code (i.e. w/o modifyng FreeRTOS or the CMSIS source code). I thought an alias would be the right tool for the job, so I tried this (in a separate source file, main.c):

void SVC_Handler(void) __attribute__ ((alias ("vPortSVCHandler")));

这会导致:错误:'SVC_HANDLER别名为未定义的符号vPortSVCHandler

原来,根据这里 HTTP GCC文档://gcc.gnu。组织/ onlinedocs / GCC /功能-Attributes.html ,为了使用别名属性,你不能别名翻译单元之外的象征。所以,我想我会尝试的extern 符号到main.c中,像这样:

Turns out, according to GCC documentation here http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html, in order to use the alias attribute, you cannot alias a symbol outside of the translation unit. So I thought I'd try to extern the symbol into main.c like so:

extern void vPortSVCHandler( void ) __attribute__ (( naked ));
void SVC_Handler(void) __attribute__ ((alias ("vPortSVCHandler")));

这会产生同样的错误。任何建议???

This generates the same error. Any suggestions???

我真的想避免修改要么库。我知道我可以写一个函数 SVC_HANDLER ,简单地调用 vPortSVCHandler ,但可能的不必要开销的ISR增加(可能取决于优化设置)。注:FreeRTOS的例子通过自定义启动文件做到这一点。我正在寻找一种方法来从C的或做的我的链接脚本。

I would really like to avoid modifying either of the libraries. I know I could write a function SVC_Handler that simply calls vPortSVCHandler, but that could add unnecessary overhead to the ISR (possibly depending on optimization settings). Note: The FreeRTOS examples accomplish this via a custom startup file. I'm looking for a way to do this from C or my linker script.


  • 编译器版本:gcc版本4.5.2(的Sourcery G ++精简版2011.03-42)

  • 目标:手臂无-EABI

推荐答案

您应该能够要么链接脚本,或者通过相应的选项来连接器,如要做到这一点。为LD, - defsym = SVC_HANDLER = vPortSVCHandler

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

请参阅Binutils的文档的LD <获得更多的信息href=\"http://sourceware.org/binutils/docs-2.21/ld/Options.html#index-g_t_002d_002ddefsym_003d_0040var_007bsymbol_007d_003d_0040var_007bexp_007d-163\"><$c$c>--defsym选项​​,<一href=\"http://sourceware.org/binutils/docs-2.21/ld/Simple-Assignments.html#Simple-Assignments\">assignments在链接脚本

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

这篇关于GCC别名功能翻译单元-AKA-的外面是这甚至对工作的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆