GCC arm-none-eabi (Codesourcery) 和 C++ 异常 [英] GCC arm-none-eabi (Codesourcery) and C++ Exceptions

查看:22
本文介绍了GCC arm-none-eabi (Codesourcery) 和 C++ 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Raisonance 的 Ride7/Codesourcery(又名 Sourcery CodeBench Lite)和一块 STM32F4 板来开发裸机 HMI 平台.

I am using Raisonance's Ride7/Codesourcery (a.k.a Sourcery CodeBench Lite) with an STM32F4 board developing a bare metal HMI platform.

我将在这个系统中使用 C++ 异常,但我抛出的任何异常都以写入标准错误的递归终止"错误结束.

I will be making use of C++ exceptions in this system, but any exception I throw ends with a "Terminate called recursively" error written to stderr.

重现问题的代码:(main.cpp)

Code to reproduce the problem: (main.cpp)

int main(void)
{
    try {
        throw 1;
    }
    catch (...) {
        printf("caught");
    }
}

我已经尝试过 Raisonance 和其他来源的解决方案,但没有收到任何可操作的帮助.

I've already tried Raisonance and other sources for a resolution, and have not received any actionable help.

潜在问题/解决方案 1:

我在其他论坛上问过,他们提到我需要在我的启动程序集文件中调用静态构造来初始化展开表(至少我认为他们在谈论),但我不知道该怎么做这个.

I've asked on other forums and they mention I need to call static constructions in my startup assembly file to initialize the unwind tables (at least that's what I think they are talking about), but I have no idea how to do this.

潜在问题/解决方案 2

我还在 binutils/gas 中发现了一个错误,这可能是我在这里出现问题的根源 (http://sourceware.org/bugzilla/show_bug.cgi?id=13449).我一直在尝试使用此补丁构建我自己的工具链版本,但这正在变成一个自己的项目,但尚未成功.

I have also discovered a bug in binutils/gas that may be the source of my problems here (http://sourceware.org/bugzilla/show_bug.cgi?id=13449). I've been trying to build my own version of the toolchain with this patch, but that's turning into a project of its own, and have not yet succeeded.

问题

我是否需要在代码中做一些事情来利用 C++ 异常,或者这可能是工具链中的一个错误?如果是前者,请详细说明.

Do I need to do something in code to make use of C++ exceptions, or is this likely a bug in the toolchain? If the former, please elaborate.

推荐答案

经过一些不必要的劝说后,Raisonance 最终通过修改其默认链接器脚本解决了问题.发布整个链接器脚本对我来说可能不合法,但这是人们需要知道的知识

After some persuasion that shouldn't have been necessary, Raisonance finally came through with a modification to their default linker script that fixed the problem. It may not be legal for me to post the entire linker script, but here's the knowledge that one needs to know

将此添加到 .text 部分

Add this to the .text section

*(.eh_frame)

添加这些部分(根据您在链接描述文件中设置的内存块命名 YourMemory.我的是 Flash)

Add these sections (name YourMemory according to the memory blocks you've set up in your linker script. Mine was Flash)

.ARM.extab :
{
    *(.ARM.extab* .gnu.linkonce.armextab.*)
} >YourMemory

.ARM :
{
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
} >YourMemory

确保这一行出现在 bss 部分

Ensure this line occurs in the bss section

*(.bss*)

在这个任务中,我遇到了以下有用的资源

While on this quest, I ran across the following useful resources

这篇关于GCC arm-none-eabi (Codesourcery) 和 C++ 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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