2014年(5)
分类: 嵌入式
2014-03-05 18:31:14
原文地址:关于R_ARM_CALL编译错误 作者:wloveg
原文地址:http://hi.baidu.com/vim_li/blog/item/5ae3f839749701e515cecbc9.html
1、刚刚完成bootloader部分的框架及Makefile,写了几个driver,编译后,链接时,出现下面错误:
ipl/ipl.o: In function `low_level_init':
ipl.c:(.text+0x28): relocation truncated to fit: R_ARM_CALL against symbol `system_clk_init' defined in .text section in /work/new_plat/bootloader/drivers/libdrivers.a(clock.o)
ipl.c:(.text+0x2c): relocation truncated to fit: R_ARM_CALL against symbol `serial_init' defined in .text section in /work/new_plat/bootloader/drivers/libdrivers.a(serial.o)
make: *** [bootloader] Error 1
原因:外部函数调用时,指令跳转返回太长,超出了ARM instruction的范围(The maximum branch is +/- 32Mbytes in ARM mode and +/- 4Mbytes in Thumb mode.)
解决方法:
对于C文件来说,编译选项CFLAGS加入'-mlong-calls'选项;
对汇编文件来说,使用如下的跳转指令
ldr r4, =func
mov lr, pc
bx r4