[U-Boot-Users] multiple definition of __udivsi3 when using divide operation on unsigned long numbers

Dirk Behme dirk.behme at googlemail.com
Tue Mar 25 07:19:39 CET 2008


Gururaja Hebbar K R wrote:
> Hi,
> 
> I am trying to compile uboot 1.3.1 for arm926ejs processor. i am using
> CodeSourcery arm-none-linux-gnueabi toolchain (gcc version 4.2.1
> (CodeSourcery Sourcery G++ Lite 2007q3-51)) . 
> 
> i am trying to write a driver for our on board mmc controller. i need to
> do multiply and divide operation as below.
> 
> unsigned long long c;
> static int lc69_mmci_clk = 0;
> unsigned int timeout_ns;
> 
> <snip>
> <snip>
> <snip>
> 
> c = (unsigned long long)timeout_ns * lc69_mmci_clk;
> c = c / 1000000000UL;

Don't do this. Compiler/Linker then tries to use math from libraries 
coming with your tool chain. Normally, U-Boot should be completely 
independent of any external libraries.

Option is to modify your code that compiler/linker doesn't need 
external libraries:

- Try to use shift operation instead of div. E.g. "c = c >> x"

- If this doesn't work, have a look to U-Boot's lib_arm directory and 
use only math available there. E.g (nand_util.c): do_div(n, opts->length);

Cheers

Dirk

> while compilling i am getting an error as below.
> 
>                 cd /home/guru/project/u_boot/Ubuild &&
> arm-none-linux-gnueabi-ld -Bstatic -T
> /home/guru/project/u_boot/u-boot/board/kboard/u-boot.lds -Ttext 0x200000
> $UNDEF_SYM cpu/arm926ejs/start.o \
>                         --start-group lib_generic/libgeneric.a
> board/kboard/libkboard.a cpu/arm926ejs/libarm926ejs.a lib_arm/libarm.a
> fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a
> fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
> net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a
> drivers/block/libblock.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a
> drivers/input/libinput.a drivers/misc/libmisc.a drivers/mtd/libmtd.a
> drivers/mtd/nand/libnand.a drivers/mtd/nand_legacy/libnand_legacy.a
> drivers/mtd/onenand/libonenand.a drivers/net/libnet.a
> drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a
> drivers/pcmcia/libpcmcia.a drivers/rtc/librtc.a
> drivers/serial/libserial.a drivers/usb/libusb.a drivers/video/libvideo.a
> post/libpost.a post/drivers/libpostdrivers.a common/libcommon.a
> libfdt/libfdt.a --end-group -L
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1 -lgcc \
>                         -Map u-boot.map -o u-boot
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivsi3.o): In function `__aeabi_uidiv':
> (.text+0x0): multiple definition of `__udivsi3'
> lib_arm/libarm.a(_udivsi3.o):/home/guru/project/u_boot/u-boot/lib_arm/_u
> divsi3.S:17: first defined here
> arm-none-linux-gnueabi-ld: ERROR: Source object
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivdi3.o) has EABI version 5, but target u-boot
> has EABI version 0
> arm-none-linux-gnueabi-ld: failed to merge target specific data of file
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivdi3.o)
> arm-none-linux-gnueabi-ld: ERROR: Source object
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivsi3.o) has EABI version 5, but target u-boot
> has EABI version 0
> arm-none-linux-gnueabi-ld: failed to merge target specific data of file
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivsi3.o)
> arm-none-linux-gnueabi-ld: ERROR: Source object
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_clz.o) has EABI version 5, but target u-boot has
> EABI version 0
> arm-none-linux-gnueabi-ld: failed to merge target specific data of file
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_clz.o)
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivdi3.o):(.ARM.exidx+0x0): undefined reference to
> `__aeabi_unwind_cpp_pr0'
> make: *** [/home/guru/project/u_boot/Ubuild/u-boot] Error 1
> 
> when i checked on the internet for this error few
> (http://bugzilla.openmoko.org/cgi-bin/bugzilla/attachment.cgi?id=7&actio
> n=view) recommended about removing -mabi from config script.
> 
> -PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
> +PLATFORM_CPPFLAGS +=$(call cc-option)
>  PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call
> cc-option,-malignment-traps,))
> 
> when i try this, i get a different error. 
> 
>                 cd /home/guru/project/u_boot/Ubuild &&
> arm-none-linux-gnueabi-ld -Bstatic -T
> /home/guru/project/u_boot/u-boot/board/kboard/u-boot.lds -Ttext 0x200000
> $UNDEF_SYM cpu/arm926ejs/start.o \
>                         --start-group lib_generic/libgeneric.a
> board/kboard/libkboard.a cpu/arm926ejs/libarm926ejs.a lib_arm/libarm.a
> fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a
> fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
> net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a
> drivers/block/libblock.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a
> drivers/input/libinput.a drivers/misc/libmisc.a drivers/mtd/libmtd.a
> drivers/mtd/nand/libnand.a drivers/mtd/nand_legacy/libnand_legacy.a
> drivers/mtd/onenand/libonenand.a drivers/net/libnet.a
> drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a
> drivers/pcmcia/libpcmcia.a drivers/rtc/librtc.a
> drivers/serial/libserial.a drivers/usb/libusb.a drivers/video/libvideo.a
> post/libpost.a post/drivers/libpostdrivers.a common/libcommon.a
> libfdt/libfdt.a --end-group -L
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1 -lgcc \
>                         -Map u-boot.map -o u-boot
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_dvmd_lnx.o): In function `__div0':
> (.text+0x8): undefined reference to `raise'
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_divdi3.o):(.ARM.exidx+0x0): undefined reference to
> `__aeabi_unwind_cpp_pr0'
> /home/guru/project/original/arm-2007q3/bin/../lib/gcc/arm-none-linux-gnu
> eabi/4.2.1/libgcc.a(_udivdi3.o):(.ARM.exidx+0x0): undefined reference to
> `__aeabi_unwind_cpp_pr0'
> make: *** [/home/guru/project/u_boot/Ubuild/u-boot] Error 1
> 
> 
> Does anyone has a better solution for this. 
> 
> Thanks in advance
> 
> Regards
> Gururaja
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
> 





More information about the U-Boot mailing list