连接时出错,(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'

 

文件1:crt0.s
.text
.global _start
_start:
        ldr r0,=0x53000000      @WTCON
        mov r1,#0
        str r1,[r0]             @close watchdog
        ldr sp,=4096
        bl main
halt_loop:
        b halt_loop
.end

文件2:led_on_c.c
#define GPBCON (*(volatile unsigned long *)0x56000010)
#define GPBDAT (*(volatile unsigned long *)0x56000014)
int main()
{
        GPBCON=0x00000400;
        GPBDAT=0x00000000;
        return 0;
}

文件3:makefile
led_on_c.bin:crt0.s led_on_c.c
        arm-linux-gcc -g -c -o crt0.o crt0.s
        arm-linux-gcc -g -c -o led_on_c.o led_on_c.c
        arm-linux-ld -Ttext 0x00000000 -g crt0.o led_on_c.o -o led_on_c_elf
        arm-linux-objcopy -O binary -S led_on_c_elf led_on_c.bin
        arm-linux-objdump -D -m arm led_on_c_elf > led_on_c.dis
clean:
        rm -f led_on_c.dis led_on_c.bin led_on_c_elf *.o

执行make,给出下面错误提示:
arm-linux-gcc -g -c -o crt0.o crt0.s
arm-linux-gcc -g -c -o led_on_c.o led_on_c.c
arm-linux-ld -Ttext 0x00000000 -g crt0.o led_on_c.o -o led_on_c_elf
led_on_c.o.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
make: *** [led_on_c.bin] Error 1

提示的错误信息是EABI不支持导致的,建议编译裸奔程序时使用3.4.5的交叉编译器,EABI使用的很多代码(特别是汇编)可能会出错,目前网络上还没有找到专门介绍EABI编译器的编程的文档。修改etc/profile文件的配置,然后source /etc/profile即可

 

arm-linux-gcc加上-nostdlib选项也OK

因为

-nostdlib
不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器。这个选项常用于编译内核、bootloader等程序,它们不需要启动文件、标准库文件。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值