EmbDev.net

Forum: ARM programming with GCC/GNU tools compile error of undefined reference to "__udivsi3"


von Min G. (minge519)


Rate this post
useful
not useful
Hi everyone,

I got a question when I use integer division of

x= x / 1000;

The compile error is undefined reference to "__udivsi3".

It seems an tnteger calculation header file is not included.

Could anybody help me? thanks.

Min Ge

von Martin Thomas (Guest)


Rate this post
useful
not useful
Min Ge wrote:
> The compile error is undefined reference to "__udivsi3".

Do the linker-parameters include -lgcc?


Martin Thomas

von ayman (Guest)


Rate this post
useful
not useful
Martin Thomas wrote:
> Min Ge wrote:
>> The compile error is undefined reference to "__udivsi3".
>
> Do the linker-parameters include -lgcc?
>
>
> Martin Thomas

hi, I have the same problem. Please tell me where I add the option
-lgcc.


this is my console output :

make -k all
..linking
arm-elf-ld -v -Map main.map -Tlpc2214-rom.ld -o main.out boot.o system.o
rs232.o blink.o main.o
rs232.o: In function `UART0Init':
/cygdrive/c/temp/workspace/serial/rs232.c:9: undefined reference to
`__udivsi3'
rs232.o: In function `UART1Init':
/cygdrive/c/temp/workspace/serial/rs232.c:57: undefined reference to
`__udivsi3'
GNU ld version 2.17
make: *** [main.out] Error 1
make: Target `all' not remade because of errors.


I'm waiting for your answer thanks

von Stefan (Guest)


Rate this post
useful
not useful
ayman wrote:
> hi, I have the same problem. Please tell me where I add the option
> -lgcc.

In Makefile look for the section with LDFLAGS and add (append) the -lgcc
flag to the flags already defined e.g. with

LDFLAGS += -lgcc

Greetings
Stefan

von Martin Thomas (Guest)


Rate this post
useful
not useful
> arm-elf-ld -v -Map main.map -Tlpc2214-rom.ld -o main.out boot.o system.o

It's easier to use the compiler-frontend (arm-elf-gcc) for linking since
this will "adjust" the search path for needed libgcc.a "automatically".
See for example the makefile that come with the WinARM Examples in the
package or on my web-site.

Martin Thomas

von Anish Y. (Company: MOSCHIP) (anishkhanna)


Rate this post
useful
not useful
Hi Stefan,

I am directly using the below command for arc cross compilation, it is 
giving below error, how can i rectify this error.

anish@MOSDROID:~/arc/arc_basic/arc$ arc-elf32-ld -T u-boot.lds boot.o 
serial_pl01x.o hello.o -L 
/firma/anish/arc/usr/local/arc/lib/gcc/arc-elf32/3.4.5/libgcc.a -Map 
boot.map -o uboot
serial_pl01x.o(.text+0x38): In function `serial_init':
: undefined reference to `__udivsi3'
arc-elf32-ld: Error: Overflow detected in relocation value for symbol 
"__udivsi3".
Relocation value should be between 16777215 and -16777216 whereas it is 
-1562312800.
Relocation type is:R_ARC_S25W_PCREL
FileName:serial_pl01x.o
Section Name:.text
Offset in Section:56
arc-elf32-ld: final link failed: Bad value

I even tried giving -lgcc, which is giving below error.
anish@MOSDROID:~/arc/arc_basic/arc$ arc-elf32-ld -T u-boot.lds boot.o 
serial_pl01x.o hello.o -lgcc -Map boot.map -o uboot
arc-elf32-ld: cannot find -lgcc
anish@MOSDROID:~/arc/arc_basic/arc$

von Johann L. (gjlayde)


Rate this post
useful
not useful
Read the posts above:

Use foo-gcc as linker driver, not foo-ld directly.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.