Re: [arm-gnu] arm-none-gnueabi can't divide with -Os? (undefined reference to `__aeabi_uidiv')
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [arm-gnu] arm-none-gnueabi can't divide with -Os? (undefined reference to `__aeabi_uidiv')
- To: "Andrew Kohlsmith (mailing lists account)" <aklists@xxxxxxxxxx>
- Subject: Re: [arm-gnu] arm-none-gnueabi can't divide with -Os? (undefined reference to `__aeabi_uidiv')
- From: Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
- Date: Tue, 02 Mar 2010 11:00:50 +0300
On 3/2/10 7:09 AM, Andrew Kohlsmith (mailing lists account) wrote:
Good evening, everyone,
I have a standalone embedded application and I'm having a bit of a time trying
to get integer division to work. I'm using the gcc from the arm-2009q3-68-arm-
none-eabi.bin installer on the site, installed to my home directory using the
default install.
I'm building for an LPC2103 system with the following command:
arm-none-eabi-gcc -g -Os -fno-builtin -mcpu=arm7tdmi -c -o rtc.o rtc.c
The problem occurs at link time:
arm-none-eabi-ld -T rom.ld -Map foo.map --cref -o foo boot.o main.o rtc.o
oled.o spiflash.o uart.o ubcsp.o vibe.o rle.o button.o font.o printf.o irq.o
rtc.o: In function `udelay':
/home/andrew/foo/rtc.c:18: undefined reference to `__aeabi_uidiv'
We always recommend using the GCC driver to link the programs. That way
the driver can select the correct libraries for the CPU you building an
application for. E.g., the link command may look approximately
$ arm-none-eabi-gcc -g -mcpu=arm7tdmi -T rom.ld -Wl,-Map=foo.map
-Wl,--cref -o foo <objects>
(you can pass linker-specific options using the `-Wl' prefix).
make: *** [foo] Error 1
Now line 18 of rtc.c is just a divide:
ticks /= 15;
__aeabi_uidiv is part of libgcc.a. If I change the routine so the divide does
not occur, the embedded code works fine. If I add libgcc.a manually to the ld
line, the code will build, but causes the CPU to enter abort mode.
That is because you are likely specifying a libgcc.a compiled for an
incompatible CPU. For more information see chapter `Library
Configurations' in the Getting Started Guide.
Regards,
--
Maxim Kuvyrkov
CodeSourcery
maxim@xxxxxxxxxxxxxxxx
(650) 331-3385 x724