最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】uboot交叉编译出错:gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise’

Uboot crifan 7329浏览 0评论

【问题】

折腾:

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译uboot

编译最后出错:

UNDEF_SYM=`arm-xscale-linux-gnueabi-objdump -x lib_generic/libgeneric.a board/whgs/libwhgs.a cpu/pxa/libpxa.a lib_arm/libarm.a  net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
		arm-xscale-linux-gnueabi-ld -Bstatic -T /home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs/u-boot.lds -Ttext 0x5c010000  $UNDEF_SYM cpu/pxa/start.o \
			--start-group lib_generic/libgeneric.a board/whgs/libwhgs.a cpu/pxa/libpxa.a lib_arm/libarm.a  net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a --end-group -L /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/../lib/gcc/arm-xscale-linux-gnueabi/4.6.0 -lgcc \
			-Map u-boot.map -o u-boot
/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/../lib/gcc/arm-xscale-linux-gnueabi/4.6.0/libgcc.a(_dvmd_lnx.o): In function `__aeabi_ldiv0':
/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/gcc-4.6.0/libgcc/../gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise'
make: *** [u-boot] Error 1
crifan@ubuntu:u-boot-1.1.4-whgs$ 

即:

xxx/libgcc.a(_dvmd_lnx.o): In function `__aeabi_ldiv0′:

xxx/gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise’

如图:

gcc config arm lib1funcs.asm 1266 undefined reference to raise

【解决过程】

1.参考:

lib1asmfuncs.asm calls raise unconditionally

但是看不太懂。

2. 参考:

[Buildroot] undefined reference to `raise’ when linking with libgcc

遇到类似问题,但是没说怎么解决。

3.这里也看到讨论:

ibotlog2html for #crosstool-ng

但是还是不知道如何解决。

貌似需要重新build一个???

4.参考:

[Bug c/31798] New: lib1funcs.asm:1000: undefined reference to `raise’

那人是自己手动添加一个了空的raise()函数而使得可以正常编译了。

此处,暂不用这种方法。

5.参考其回复:

[Bug target/31798] lib1funcs.asm:1000: undefined reference to `raise’

说到了:当发生除于0才会出现除的函数,其中会去触发__div0函数

以及,说不是编译器的bug,而需要自己解决:

要么说动实现自己的_div0

要么重新用不同的配置重新去编译交叉编译器。

但是此处:

前者,不太会。

后者,很是麻烦。

所以都放弃。

6.参考:

Re: [nuttx] commit 4573 broke the calypso platform.

其自己解决了:

I fixed locally by linking to src/target/firmware/lib/lib1funcs.S in osmocombb

and doing that:

— a/src/target/firmware/lib/lib1funcs.S

+++ b/src/target/firmware/lib/lib1funcs.S

@@ -323,6 +323,7 @@ ENTRY(__aeabi_idivmod)

sub r1, r1, r3

mov pc, lr

+ENTRY(__aeabi_ldiv0)

Ldiv0:

str lr, [sp, #-8]!

@@ -332,3 +333,6 @@ Ldiv0:

ENTRY(__div0)

mov pc, lr

+

+ENTRY(__aeabi_unwind_cpp_pr0)

And linking to it in Make.defs…

但是还是不太想要这种方法。

7.参考:

build uClibc toolchains using Buildroot for GM812x

其是:

  1. 直接修改原始檔,將 raise() 直接回傳 zero. (只是不清楚要改哪,所以跳過)
  2. 直接使用原廠提供的glibc 產生的 nsboot.bin檔。不再產生uClibc 的nsboot.bin。 

此处,也不太会弄。

8.然后看到了

commit 4573 broke the calypso platform

中也有类似的解决办法,但是还是觉得不好。

9.后来看到:

Source object XXX has EABI version 4, but target u-boot has EABI version 0

其中的几个人的解释,比较清楚:

U-Boot is not a GNU/Linux application. However, you’re using the GNU/Linux toolchain to compile it — so the libraries assume the presence of a GNU/Linux C library. In this case, the division routine wants to call "raise" to signal a division-by-zero exception.

People often try to abuse the GNU/Linux toolchain to build U-Boot because they want to use the same toolchain that they use to build the Linux kernel and GNU/Linux applications. But, U-Boot is really a bare-metal application, and, as such, should be built with a bare-metal toolchain, like our "ARM EABI" toolchains. There are often these kinds of problems with U-Boot when moving between different architectures or toolchain versions because the U-Boot source code has tricks to try to make the GNU/Linux toolchain work, and those tricks only work with

particular toolchains.

和:

U-boot explicitly compiles its binaries for ARM with -mabi=apcs-gnu, not EABI, so linking to any EABI compiled libgcc will cause the same error message.

In mainline U-boot currently all libgcc-provided-routines for ARM are also implemented in the lib_arm directory. (yes, it is dirty, but it is done this way for ARM). So, as long as there is an implementation in the lib_Arm directory, nothing will be used from libgcc, and this error will not be seen, even if you use a linux destined compiler.

I noticed that this question was about an very out-dated version of U-boot, namely 1.1.4, so that might be cause some troubles as well.

So, use a proper compiler toolchain (not EABI, but surely a bare metal edition). Several options are possible, you can also use the ARM-ELDK from denx.de

然后去试试后面给出的解决办法:

(1)修改Makefile,改为:

# Add GCC lib
#PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc

(2)再去修改:lib_generic/vsprintf.c

修改为:

#include <linux/string.h>
#include <linux/ctype.h>

#ifdef CFG_64BIT_VSPRINTF
#include <div64.h>
#endif

#include <common.h>

...


#define SPECIAL	32		/* 0x */
#define LARGE	64		/* use 'ABCDEF' instead of 'abcdef' */

#if 0
#define do_div(n,base) ({ \
	int __res; \
	__res = ((unsigned long) n) % (unsigned) base; \
	n = ((unsigned long) n) / (unsigned) base; \
	__res; \
})
#endif

#ifdef CFG_64BIT_VSPRINTF
static char * number(char * str, long long num, int base, int size, int precision ,int type)
#else

结果重新编译,则会导致更多的错误:

crifan@ubuntu:u-boot-1.1.4-whgs$ make clean
find . -type f \
		\( -name 'core' -o -name '*.bak' -o -name '*~' \
		-o -name '*.o'  -o -name '*.a'  \) -print \
		| xargs rm -f
rm -f examples/hello_world examples/timer \
	      examples/eepro100_eeprom examples/sched \
	      examples/mem_to_mem_idma2intr examples/82559_eeprom \
	      examples/test_burst
rm -f tools/img2srec tools/mkimage tools/envcrc tools/gen_eth_addr
rm -f tools/mpc86x_clk tools/ncb
rm -f tools/easylogo/easylogo tools/bmp_logo
rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
rm -f tools/env/fw_printenv tools/env/fw_setenv
rm -f board/cray/L1/bootscript.c board/cray/L1/bootscript.image
rm -f board/trab/trab_fkt board/voiceblue/eeprom
rm -f board/integratorap/u-boot.lds board/integratorcp/u-boot.lds
crifan@ubuntu:u-boot-1.1.4-whgs$ make whgs_config
Configuring for whgs board...
crifan@ubuntu:u-boot-1.1.4-whgs$ make
...
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common'
UNDEF_SYM=`arm-xscale-linux-gnueabi-objdump -x lib_generic/libgeneric.a board/whgs/libwhgs.a cpu/pxa/libpxa.a lib_arm/libarm.a  net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
		arm-xscale-linux-gnueabi-ld -Bstatic -T /home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs/u-boot.lds -Ttext 0x5c010000  $UNDEF_SYM cpu/pxa/start.o \
			--start-group lib_generic/libgeneric.a board/whgs/libwhgs.a cpu/pxa/libpxa.a lib_arm/libarm.a  net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a --end-group  \
			-Map u-boot.map -o u-boot
cpu/pxa/libpxa.a(interrupts.o): In function `udelay_masked':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/cpu/pxa/interrupts.c:197: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/cpu/pxa/interrupts.c:202: undefined reference to `__aeabi_uidiv'
net/libnet.a(tftp.o): In function `TftpHandler':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/net/tftp.c:230: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/net/tftp.c:232: undefined reference to `__aeabi_uidivmod'
net/libnet.a(tftp.o): In function `TftpStart':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/net/tftp.c:372: undefined reference to `__aeabi_uidivmod'
net/libnet.a(bootp.o): In function `BootpRequest':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/net/bootp.c:672: undefined reference to `__aeabi_uidiv'
drivers/libdrivers.a(onenand_uboot.o): In function `flash_print_info':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_uboot.c:65: undefined reference to `__aeabi_uidivmod'
drivers/libdrivers.a(onenand_base.o): In function `onenand_command':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:203: undefined reference to `__aeabi_lasr'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:208: undefined reference to `__aeabi_lasr'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:209: undefined reference to `__aeabi_lasr'
drivers/libdrivers.a(onenand_base.o): In function `onenand_update_bufferram':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:468: undefined reference to `__aeabi_lasr'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:469: undefined reference to `__aeabi_lasr'
drivers/libdrivers.a(onenand_base.o):/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:439: more undefined references to `__aeabi_lasr' follow
drivers/libdrivers.a(onenand_base.o): In function `onenand_probe':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_base.c:1770: undefined reference to `__aeabi_uidiv'
drivers/libdrivers.a(onenand_bbt.o): In function `onenand_isbad_bbt':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/onenand_bbt.c:155: undefined reference to `__aeabi_lasr'
common/libcommon.a(cmd_date.o): In function `mk_date':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common/cmd_date.c:146: undefined reference to `__aeabi_idiv'
common/libcommon.a(dlmalloc.o): In function `memalign':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common/dlmalloc.c:2779: undefined reference to `__aeabi_uidivmod'
common/libcommon.a(lists.o): In function `ExpandListSpace':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common/lists.c:158: undefined reference to `__aeabi_idiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common/lists.c:160: undefined reference to `__aeabi_idiv'
lib_generic/libgeneric.a(display_options.o): In function `print_size':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic/display_options.c:53: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic/display_options.c:55: undefined reference to `__aeabi_uidiv'
lib_generic/libgeneric.a(vsprintf.o): In function `number':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic/vsprintf.c:162: undefined reference to `do_div'
lib_generic/libgeneric.a(zlib.o): In function `adler32':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic/zlib.c:2157: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic/zlib.c:2158: undefined reference to `__aeabi_uidivmod'
lib_generic/libgeneric.a(zlib.o): In function `inflate':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic/zlib.c:427: undefined reference to `__aeabi_uidivmod'
rtc/librtc.a(date.o): In function `GregorianDay':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:61: undefined reference to `__aeabi_idiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:61: undefined reference to `__aeabi_idiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:70: undefined reference to `__aeabi_idivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:70: undefined reference to `__aeabi_idivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:82: undefined reference to `__aeabi_idivmod'
rtc/librtc.a(date.o): In function `to_tm':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:90: undefined reference to `__aeabi_idiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:91: undefined reference to `__aeabi_idivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:94: undefined reference to `__aeabi_idiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:95: undefined reference to `__aeabi_idivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:95: undefined reference to `__aeabi_idiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:96: undefined reference to `__aeabi_idivmod'
rtc/librtc.a(date.o): In function `mktime':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:149: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:149: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/date.c:149: undefined reference to `__aeabi_uidiv'
rtc/librtc.a(pcf8563.o): In function `rtc_set':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:93: undefined reference to `__aeabi_idivmod'
rtc/librtc.a(pcf8563.o): In function `bin2bcd':
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidiv'
/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc/pcf8563.c:141: undefined reference to `__aeabi_uidivmod'
make: *** [u-boot] Error 1
crifan@ubuntu:u-boot-1.1.4-whgs$ 

10.然后看到之前的一堆人的讨论:

Re: [arm-gnu] In Function __aeabi_ldiv0 : undefined reference to ‘raise’

Re: [arm-gnu] EABI version 5, but target u-boot has EABI version 0

结果是:

此处我用的交叉编译器是arm-xscale-linux-gnueabi,是EABI的

而uboot中对于arm则显式地要求

-mabi=apcs-gnu

即非EABI的。

结果就是:

我的交叉编译器版本太新,而uboot版本太老:1.1.4

所以出了问题。

如果是用来编译比较新的,尤其是最新的uboot,应该就可以了。

11.所以,先去恢复上述的修改再说。

12.然后再想办法,如何去添加自己的raise()或者__aeabi_ldiv0。

参考:

commit 4573 broke the calypso platform

去找到之前的crosstool-ng的编译的地方:

/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/gcc-4.6.0/libgcc/../gcc/config/arm/lib1funcs.asm

可以找到相关的代码的:

/* ------------------------------------------------------------------------ */
#ifdef L_dvmd_lnx
@ GNU/Linux division-by zero handler.  Used in place of L_dvmd_tls

/* Constant taken from <asm/signal.h>.  */
#define SIGFPE	8

#ifdef __ARM_EABI__
	WEAK aeabi_idiv0
	WEAK aeabi_ldiv0
	ARM_FUNC_START aeabi_idiv0
	ARM_FUNC_START aeabi_ldiv0
#else
	ARM_FUNC_START div0
#endif

	do_push	{r1, lr}
	mov	r0, #SIGFPE
	bl	SYM(raise) __PLT__
	RETLDM	r1

#ifdef __ARM_EABI__
	FUNC_END aeabi_ldiv0
	FUNC_END aeabi_idiv0
#else
	FUNC_END div0
#endif
	
#endif /* L_dvmd_lnx */

但是也不方便改啊。

13.然后是找到了uboot-1.1.4中的,自己的一个.S汇编文件:

board/whgs/lowlevel_init.S

去编辑:

crifan@ubuntu:u-boot-1.1.4-whgs$ gedit 
arm_config.mk         CVS/                  include/              lib_nios2/            microblaze_config.mk  README
board/                disk/                 lib_arm/              lib_ppc/              mips_config.mk        rtc/
CHANGELOG             doc/                  lib_generic/          m68k_config.mk        mkconfig              tools/
common/               drivers/              lib_i386/             MAINTAINERS           net/                  u-boot.map
config.mk             dtt/                  lib_m68k/             MAKEALL               nios2_config.mk       
COPYING               examples/             lib_microblaze/       Makefile              nios_config.mk        
cpu/                  fs/                   lib_mips/             Makefile~             post/                 
CREDITS               i386_config.mk        lib_nios/             Makefile.orig         ppc_config.mk         
crifan@ubuntu:u-boot-1.1.4-whgs$ gedit board/
Display all 197 possibilities? (y or n)
crifan@ubuntu:u-boot-1.1.4-whgs$ gedit board/whgs/
config.mk            ethernetselftest.h   lowlevel_init.o      old/                 selftest.h           whgs.c
CVS/                 ethernetselftest.o   lowlevel_init.S      phycore_pxa270.h     selftest.o           whgs.o
.depend              intel.h              lowlevel_init.S.old  pxavoltage.S         smc91111.h           
ethernetselftest.c   libwhgs.a            Makefile             selftest.c           u-boot.lds           
crifan@ubuntu:u-boot-1.1.4-whgs$ gedit board/whgs/lowlevel_init.S

在文件的最后,添加上对应的raise函数:

@add empty raise() to fix (when use new EABI xscale cross compiler to) compile
@error gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise'
.globl raise
raise:
	nop
	mov	pc, lr

然后再去编译试试,看看能否消除此错误,果然消除此错误了:

crifan@ubuntu:u-boot-1.1.4-whgs$ make
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/tools'
make[1]: `.depend' is up to date.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/tools'
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post'
make[1]: `.depend' is up to date.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post'
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post/cpu'
make[1]: `.depend' is up to date.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post/cpu'
make -C tools all
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/tools'
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/tools'
make -C post all
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post'
make -C post/cpu all
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post/cpu'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post/cpu'
make -C `dirname lib_generic/libgeneric.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic'
make[1]: `libgeneric.a' is up to date.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_generic'
make -C `dirname board/whgs/libwhgs.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs'
arm-xscale-linux-gnueabi-gcc -M -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8  -D__KERNEL__ -DTEXT_BASE=0x5c010000 -I/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/../lib/gcc/arm-xscale-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv5 -mtune=xscale lowlevel_init.S whgs.c selftest.c ethernetselftest.c > .depend
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs'
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs'
arm-xscale-linux-gnueabi-gcc -Wa,-gstabs -D__ASSEMBLY__ -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8  -D__KERNEL__ -DTEXT_BASE=0x5c010000 -I/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/../lib/gcc/arm-xscale-linux-gnueabi/4.6.0/include -pipe  -DCONFIG_ARM -D__ARM__ -march=armv5 -mtune=xscale -c -o lowlevel_init.o /home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs/lowlevel_init.S
arm-xscale-linux-gnueabi-ar crv libwhgs.a whgs.o selftest.o ethernetselftest.o lowlevel_init.o
r - whgs.o
r - selftest.o
r - ethernetselftest.o
r - lowlevel_init.o
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs'
make -C `dirname cpu/pxa/libpxa.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/cpu/pxa'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/cpu/pxa'
make -C `dirname lib_arm/libarm.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_arm'
make[1]: `libarm.a' is up to date.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/lib_arm'
make -C `dirname net/libnet.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/net'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/net'
make -C `dirname disk/libdisk.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/disk'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/disk'
make -C `dirname rtc/librtc.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/rtc'
make -C `dirname dtt/libdtt.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/dtt'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/dtt'
make -C `dirname drivers/libdrivers.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers'
make -C `dirname drivers/sk98lin/libsk98lin.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/sk98lin'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/drivers/sk98lin'
make -C `dirname post/libpost.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post'
make -C `dirname post/cpu/libcpu.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post/cpu'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/post/cpu'
make -C `dirname common/libcommon.a`
make[1]: Entering directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/common'
UNDEF_SYM=`arm-xscale-linux-gnueabi-objdump -x lib_generic/libgeneric.a board/whgs/libwhgs.a cpu/pxa/libpxa.a lib_arm/libarm.a  net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
		arm-xscale-linux-gnueabi-ld -Bstatic -T /home/crifan/develop/crosscompile/wihart_gateway_6_0/old_project_lack_eclipse_project_file/BSP/Bootloader/u-boot-1.1.4-whgs/board/whgs/u-boot.lds -Ttext 0x5c010000  $UNDEF_SYM cpu/pxa/start.o \
			--start-group lib_generic/libgeneric.a board/whgs/libwhgs.a cpu/pxa/libpxa.a lib_arm/libarm.a  net/libnet.a disk/libdisk.a rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a common/libcommon.a --end-group -L /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/../lib/gcc/arm-xscale-linux-gnueabi/4.6.0 -lgcc \
			-Map u-boot.map -o u-boot
arm-xscale-linux-gnueabi-objcopy --gap-fill=0xff -O srec u-boot u-boot.srec
arm-xscale-linux-gnueabi-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin
crifan@ubuntu:u-boot-1.1.4-whgs$ 

 

 

【总结】

此处,用交叉编译器arm-xscale-linux-gnueabi(gcc-4.6.0-glibc-2.9)去编译老版本的uboot(1.1.4)而出错:

gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise’

的原因是:

Uboot是个非GNU/Linux的程序,是个裸程序(bare-metal application);

而交叉编译器arm-xscale-linux-gnueabi是GNU/Linux工具链,是可以正常编译Linux内核等东西的,

但是去编译非GNU/Linux的Uboot的话,就会出现:

当出现被0除的情况时,会调用__aeabi_ldiv0(即eabi版本的__div0),当在GNU/Linux系统中时,其会去触发系统的SIGFPE,进而调用到对应的raise(3)函数。

而此处,由于Uboot不是Linux类程序,没有对应的raise()函数,所以报错找不到。

 

解决办法是:

两种:

1.去用其他对应的配置(估计是用于指定是非GUN/Linux类程序的),重新编译一个新版本的交叉编译器,然后用新的非GNU/Linux的交叉编译器,去编译此旧版本的uboot,即可正常编译

2.修改自己的uboot,加上对应的(随便写个空的)__aeabi_ldiv0或raise函数即可。

此处选用第二种,具体做法:

此处的uboot是whgs的(即配置的时候用的是make whgs_config)

所以找到对应的汇编文件,即:

board/whgs/lowlevel_init.S

在文件最后,添加上

@add empty raise() to fix (when use new EABI xscale cross compiler to) compile
@error gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise'
.globl raise
raise:
	nop
	mov	pc, lr

然后重新编译,即可。

转载请注明:在路上 » 【已解决】uboot交叉编译出错:gcc/config/arm/lib1funcs.asm:1266: undefined reference to `raise’

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.220 seconds, using 22.98MB memory