【发布时间】:2018-02-09 22:18:37
【问题描述】:
大家晚上好,
我正在尝试在 Ada 中为基于 Arm 的微控制器编译一个简单的程序。
我在 Windows 的 Linux 子系统上安装了 gnat-5-arm-linux-gnueabi 包。
现在,使用arm-linux-gnueabi-gcc-5 -mcpu=cortex-m4 -mthumb program.adb 编译可以正常工作,但是使用arm-linux-gnueabi-ld -T flash.ld -o program.elf program.o 链接会导致错误:
program.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
我查看了现有的解决方案,但没有一个对我有用。我尝试安装gcc-arm-none-eabi 包并使用它的链接器(同样的错误),以及使用ld(不识别arm 目标)。
我的一个理论是我可能在编译或链接时使用了错误的 GNAT 包或二进制文件。因此,如果有人知道在哪里可以找到这些描述,它也可能对我有帮助:-)(有很多 GNAT 包,但只有 2 个名称中带有“arm”)
编辑:/usr/lib/gcc-cross/arm-linux-gnueabi/5/ 下有一个文件libgcc_eh.a,其中包含符号“unwind”;将此文件添加到链接器输入似乎可以解决此错误,但会出现一些新的“未定义引用”:
Incl/libgcc_eh.a(unwind-arm.o): In function 'get_eit_entry':
(.text+0x238): undefined reference to '__exidx_start'
Incl/libgcc_eh.a(unwind-arm.o): In function 'get_eit_entry':
(.text+0x23c): undefined reference to '__exidx_end'
Incl/libgcc_eh.a(unwind-arm.o): In function 'unwind_phase2':
(.text+0x334): undefined reference to 'abort'
Incl/libgcc_eh.a(unwind-arm.o): In function 'unwind_phase2_forced':
(.text+0x424): undefined reference to 'memcpy'
Incl/libgcc_eh.a(unwind-arm.o): In function 'unwind_phase2_forced':
(.text+0x478): undefined reference to 'memcpy'
Incl/libgcc_eh.a(unwind-arm.o): In function '__gnu_Unwind_Resume':
(.text+0x5b8): undefined reference to 'abort'
Incl/libgcc_eh.a(unwind-arm.o): In function '__gnu_Unwind_Resume':
(.text+0x5f4): undefined reference to 'abort'
Incl/libgcc_eh.a(pr-support.o): In function '_Unwind_GetTextRelBase':
(.text+0x4f0): undefined reference to 'abort'
【问题讨论】:
-
要检查的一件事是您是否使用了正确的异常样式 - 寻找 SJLJ 与 ZCX(Setjump/Longjump 与零成本异常)的编译指示或编译器选项,因为您的运行时可能不支持两者(并且“展开”表示涉及异常处理代码)
-
这个包好像用的是ZCX,SJLJ有不同的:
gnat-5-sjlj-arm-linux-gnueabi,所以这可能不是问题 -
哪个基于 ARM 的 MCU?并且,您是否需要在 Linux 子系统中构建,或者 Windows 工具集可以吗?
-
@BrianDrummond 我尝试这样做,但无论我使用什么组合,总会有多个未定义的引用
-
@SimonWright STM32,但在这个阶段我猜应该没关系。 Ada 程序只是一个空循环,没有任何 MCU 特定的指令。至于 Windows 工具集 - 我已经在本地 Linux 计算机上尝试过,效果相同,所以 WSL 没有问题
标签: linux gcc ada windows-subsystem-for-linux gnat