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

来源:互联网 发布:华泰证券交易软件 mac 编辑:程序博客网 时间:2024/04/30 21:57
 

文件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等程序,它们不需要启动文件、标准库文件。

原创粉丝点击