undefined reference to `__aeabi_unwind_cpp_pr0' 问题解决办法

arm-none-linux-gnueabi/bin/ld: section .ARM.extab loaded at [00201008,00201013] overlaps section .data loaded at [00201008,0020103f]
at91sam9260ek.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
main.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
gpio.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
pmc.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
sdramc.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
nandflash.o:(.ARM.exidx+0x0): more undefined references to `__aeabi_unwind_cpp_pr0' follow
nandflash.o:(.ARM.exidx+0x18): undefined reference to `__aeabi_unwind_cpp_pr1'
div0.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
udiv.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'

string.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'


问题解决:arm-none-linux-gnueabi-gcc加上-nostdlib选项即可

机理
-nostdlib
不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器。

这个选项常用于编译内核、bootloader等程序,它们不需要启动文件、标准库文件。


C语言程序执行的第一条指令。并不是main函数。生产一个C程序的可执行文件时编译器通常会在我们的代码上加几个被称为启动文件的代码--crt1.o、crti.o、

crtend.o等,他们是标准库文件。这些代码设置C程序的堆栈等,然后调用main函数。他么依赖于操作系统,在裸板上无法执行,所以我们自己写一个。

 

问题已经找到答案了,我们自己写的crt0.S就是一个启动文件,他设置好堆栈后调用main函数。因此,我们不需要系统自带的启动文件。



  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值