Arm sourcery toolchain linking error

15,221

Solution 1

Try using gcc as ld frontend. Change:

$(TOOLCHAIN)ld  -o check.elf [...]

into

$(TOOLCHAIN)gcc  -o check.elf [...]

GCC knows to add some necessary options when invoking ld.

Solution 2

Do things go any better when adding "-lgcc" to -L?

Solution 3

instead of using ld for linking i used gcc but it was including the supplied crt.o object file so i used -nostartfiles and it worked for me.

Share:
15,221
sanjay
Author by

sanjay

I Like to code in C++, Qt and c for embedded systems.

Updated on June 05, 2022

Comments

  • sanjay
    sanjay almost 2 years

    I want to use standard c function in one of my function

    void print(const char* format,...) {    
        char buffer[256];
        va_list args;
        va_start (args, format);
        vsnprintf (buffer,256,format, args);
        va_end (args);
        sendString(buffer);
    }
    

    Error coming is

    arm-none-eabi-ld  -o check.elf -T /home/sanju/Arm/check/other/ROM.ld Serial.o irq.o lowlevel.o main.o startup.o \
    -L/usr/arm-none-eabi/lib   -lc -lg  -lm
    /usr/arm-none-eabi/lib/libc.a(lib_a-svfprintf.o): In function `_svfprintf_r':
    vfprintf.c:(.text+0x688): undefined reference to `__aeabi_dcmplt'
    vfprintf.c:(.text+0xdfc): undefined reference to `__aeabi_dcmpeq'
    vfprintf.c:(.text+0x10b4): undefined reference to `__aeabi_dcmpeq'
    vfprintf.c:(.text+0x168c): undefined reference to `__aeabi_uldivmod'
    vfprintf.c:(.text+0x16a8): undefined reference to `__aeabi_uldivmod'
    vfprintf.c:(.text+0x1a48): undefined reference to `__aeabi_dcmpeq'
    vfprintf.c:(.text+0x1eac): undefined reference to `__aeabi_dcmpeq'
    /usr/arm-none-eabi/lib/libc.a(lib_a-dtoa.o): In function `quorem':
    dtoa.c:(.text+0x3c): undefined reference to `__aeabi_uidiv'
    /usr/arm-none-eabi/lib/libc.a(lib_a-dtoa.o): In function `_dtoa_r':
    dtoa.c:(.text+0x274): undefined reference to `__aeabi_dcmpeq'
    dtoa.c:(.text+0x360): undefined reference to `__aeabi_ui2d'
    dtoa.c:(.text+0x37c): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0x388): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x394): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0x3a4): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0x3b0): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x3c4): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0x3d0): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0x3e8): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0x418): undefined reference to `__aeabi_dcmpgt'
    dtoa.c:(.text+0x5a8): undefined reference to `__aeabi_ddiv'
    dtoa.c:(.text+0x5ac): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0x5b4): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0x5c0): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x5d4): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0x608): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x61c): undefined reference to `__aeabi_dcmpeq'
    dtoa.c:(.text+0x650): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x664): undefined reference to `__aeabi_dcmpeq'
    dtoa.c:(.text+0x684): undefined reference to `__aeabi_ddiv'
    dtoa.c:(.text+0x688): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0x690): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0x69c): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x6b0): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0x6fc): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0x718): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0x73c): undefined reference to `__aeabi_dcmpeq'
    dtoa.c:(.text+0xa94): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0xaa0): undefined reference to `__aeabi_dcmpeq'
    dtoa.c:(.text+0xbf8): undefined reference to `__aeabi_ddiv'
    dtoa.c:(.text+0xc2c): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0xc58): undefined reference to `__aeabi_ddiv'
    dtoa.c:(.text+0xc80): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0xc90): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0xc9c): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0xca8): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0xce8): undefined reference to `__aeabi_ddiv'
    dtoa.c:(.text+0xcf4): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0xd08): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0xd10): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0xd24): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0xd54): undefined reference to `__aeabi_dcmpgt'
    dtoa.c:(.text+0xd78): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0xd8c): undefined reference to `__aeabi_dcmpgt'
    dtoa.c:(.text+0xdd0): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0xddc): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0xe00): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0xe1c): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0xe28): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0xe30): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0xe44): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0xe64): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0xef0): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0xefc): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0xf08): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0xf24): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0xf38): undefined reference to `__aeabi_dcmpgt'
    dtoa.c:(.text+0xf54): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0x10c0): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x10e8): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x1130): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x1144): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0x114c): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0x1160): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0x119c): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x11a8): undefined reference to `__aeabi_d2iz'
    dtoa.c:(.text+0x11b0): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0x11c8): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0x1200): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0x120c): undefined reference to `__aeabi_dcmplt'
    dtoa.c:(.text+0x12cc): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x12d8): undefined reference to `__aeabi_dcmpge'
    dtoa.c:(.text+0x158c): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x159c): undefined reference to `__aeabi_i2d'
    dtoa.c:(.text+0x15b0): undefined reference to `__aeabi_dmul'
    dtoa.c:(.text+0x15bc): undefined reference to `__aeabi_dadd'
    dtoa.c:(.text+0x15ec): undefined reference to `__aeabi_dsub'
    dtoa.c:(.text+0x15f8): undefined reference to `__aeabi_dcmpgt'
    /usr/arm-none-eabi/lib/libc.a(lib_a-mprec.o): In function `__ratio':
    mprec.c:(.text+0xbc0): undefined reference to `__aeabi_ddiv'
    /usr/arm-none-eabi/lib/libc.a(lib_a-mprec.o): In function `_mprec_log10':
    mprec.c:(.text+0xbf0): undefined reference to `__aeabi_dmul'
    /usr/arm-none-eabi/lib/libc.a(lib_a-svfiprintf.o): In function `_svfiprintf_r':
    vfprintf.c:(.text+0xf30): undefined reference to `__aeabi_uldivmod'
    vfprintf.c:(.text+0xf4c): undefined reference to `__aeabi_uldivmod'
    make: *** [all] Error 1
    *** Failure: Exit code 2 ***
    

    My makefile is this

    TOOLCHAIN=arm-none-eabi-
    
    ARM_CPU=arm7tdmi
    
    VPATH= /home/sanju/Arm/check/src /home/sanju/Arm/check/other /home/sanju/Arm/check/include
    
    INCLUDE= /home/sanju/Arm/check/include
    
    CCFLAGS= -mcpu=$(ARM_CPU) -mthumb-interwork -ffunction-sections -Os -Wall
    
    ASFLAGS= -mcpu=$(ARM_CPU) -mthumb-interwork -mfpu=softfpa -Wall
    
    
    all: Serial.o irq.o lowlevel.o main.o startup.o 
    
        $(TOOLCHAIN)ld  -o check.elf -T /home/sanju/Arm/check/other/ROM.ld Serial.o irq.o 
    lowlevel.o main.o startup.o \
    
        -L/usr/arm-none-eabi/lib   -lc -lg  -lm
    
        $(TOOLCHAIN)objcopy -O ihex check.elf check.hex 
    
        $(TOOLCHAIN)objcopy -O binary check.elf check.bin 
    
    
    
    Serial.o : Serial.c Serial.h
    
        $(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $< 
    
    
    irq.o : irq.c irq.h lpc214x.h
    
        $(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $< 
    
    
    lowlevel.o : lowlevel.c lowlevel.h
    
        $(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $< 
    
    
    
    main.o : main.c lpc214x.h timer0.h Asm.h lowlevel.h type.h Serial.h
    
        $(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $< 
    
    startup.o : startup.S 
    
        $(TOOLCHAIN)as $(ASFLAGS) -o startup.o $< 
    
    
    
    
    .PHONY: clean 
    
    clean : 
    
        rm -rf *.o  *.elf *.hex *.o *.bin 
    

    In the target all it fails in linking. I have tried the example with arm-elf toolchain there also i am getting some errors.I have googled a lot for it but did not find any solution for it.

  • sanjay
    sanjay almost 11 years
    i tried that but i am using linux os so instead of -lgcc -lg is there and i have added that
  • sanjay
    sanjay almost 11 years
    i used gcc instead of ld but i am getting some others because gcc try to link it with some crt.o and some symbols are undefined for that file.
  • Multisync
    Multisync over 6 years
    I found this question through Google, and this actually solved my problem. How comes that gcc is smarter than ld? Shouldn't we stop using ld in favor of gcc at all then?
  • Turbo J
    Turbo J over 6 years
    Note that gcc is just a frontend for ld here. It can tell you the actual ld command line used.