2008-03-11 11:57:51     Calling functions

Document created by Aaronwu Employee on Sep 17, 2013
Version 1Show Document
  • View in full screen mode

2008-03-11 11:57:51     Calling functions

Henning Manteuffel (GERMANY)

Message: 52339    Hello,

 

I have a problem when I want to call a function within a U-Boot library from an external program. This is an example c-code (test.c):

 

    #include <common.h>

    #include <exports.h>

    #include <../include/asm-blackfin/arch-bf537/cdefBF537.h>

 

    int main(void)

    {

        unsigned char a[20], b[20];

        memcpy(a,b,20);

        return 0;

    }

 

 

 

And this is my build script:

 

    bfin-uclinux-gcc -g  -O2  -mcpu=bf537 -ffixed-P5  -D__KERNEL__ -DTEXT_BASE=do-not-use-me  -I../include -fno-builtin -ffreestanding -nostdinc -isystem /opt/uClinux/bfin-uclinux/lib/gcc/bfin-uclinux/4.1.1/include -pipe  -DCONFIG_BLACKFIN -Wall -Wstrict-prototypes -c -o test.o test.c

 

 

    bfin-uclinux-ld -g  -Ttext 0x1000 \

                -o test -e _main test.o \

                /home/hm/ti6mb/u-boot-mmc/lib_blackfin/libblackfin.a \

                /home/hm/ti6mb/u-boot-mmc/cpu/bf537/libbf537.a \

                -L/opt/uClinux/bfin-uclinux/lib/gcc/bfin-uclinux/4.1.1 -lgcc

 

          

Compiling is OK, but the linker has undefined references, e.g:

 

    /home/hm/ti6mb/u-boot-mmc/cpu/bf537/cpu.c:82: undefined reference to `icplb_table'

 

icplb_table is defined in lib_blackfin/board.c, which is contained in the library lib_blackfin/libblackfin.a.

libblackfin.a is already referenced in the linker-command.

 

Why can't the program be linked? Other functions like printf or getc work properly.

Thank you

QuoteReplyEditDelete

 

 

2008-03-11 12:11:09     Re: Calling functions

Mike Frysinger (UNITED STATES)

Message: 52341    dont include Blackfin header files like that.  include <asm/blackfin.h> and everything else will automatically get included for you.

 

that isnt how you link standalone applications.  please refer to the files in examples/ for the proper compile/linking steps.

Attachments

    Outcomes