0

I've a problem with the classic math function linking of my bare metal program with blackfin tool chain linker. I tried many things but I cannot see why the libm.a does't provide the definitions for the function it use. Do I need to add an extra library? if yes which one?

I've put my linker verbose lign with linked libraries and the example linking error I got.

Thanks,

William

bfin-elf-ld -v  -o test_ad1836_driver -T  coreb_test_ad1836_driver.lds  --just-symbol  ../../icc_core/icc queue.o ezkit_561.o  heap_2.o  port.o tasks.o test_ad1836_driver.o list.o croutine.o user_isr.o bfin_isr.o app_c.o context_sl_asm.o cycle_count.o CFFT_Rad4_NS_NBRev.o fir_decima.o fir_decima_spl.o math_tools.o -Ttext 0x3c00000   -L /opt/uClinux/bfin-elf/bfin-elf/lib -lbffastfp -lbfdsp -lg -lc -lm -Map=test_ad1836_driver.map 
argv[0]      = 'bfin-elf-ld'
bindir       = '/opt/uClinux/bfin-elf/bin/'
tooldir      = '/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/'
linker       = '/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/ld.real'
elf2flt      = '/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/elf2flt'
nm           = '/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/nm'
objdump      = '/opt/uClinux/bfin-elf/bin/bfin-elf-objdump'
objcopy      = '/opt/uClinux/bfin-elf/bin/bfin-elf-objcopy'
ldscriptpath = '/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/../lib'
Invoking: '/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/ld.real' '-v' '-o' 'test_ad1836_driver' '-T' 'coreb_test_ad1836_driver.lds' '--just-symbol' '../../icc_core/icc' 'queue.o' 'ezkit_561.o' 'heap_2.o' 'port.o' 'tasks.o' 'test_ad1836_driver.o' 'list.o' 'croutine.o' 'user_isr.o' 'bfin_isr.o' 'app_c.o' 'context_sl_asm.o' 'cycle_count.o' 'CFFT_Rad4_NS_NBRev.o' 'fir_decima.o' 'fir_decima_spl.o' 'math_tools.o' '-Ttext' '0x3c00000' '-L' '/opt/uClinux/bfin-elf/bfin-elf/lib' '-lbffastfp' '-lbfdsp' '-lg' '-lc' '-lm' '-Map=test_ad1836_driver.map'
GNU ld version 2.17
/opt/uClinux/bfin-elf/bfin-elf/lib/libm.a(w_atan2.o): In function `atan2':
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/w_atan2.c:96: undefined reference to `__eqdf2'
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/w_atan2.c:96: relocation truncated to fit: R_BFIN_PCREL24 against undefined symbol `__eqdf2'
.....
/opt/uClinux/bfin-elf/bfin-elf/lib/libm.a(e_sqrt.o): In function `_ieee754_sqrt':
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/e_sqrt.c:110: undefined reference to `__muldf3'
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/e_sqrt.c:110: undefined reference to `__adddf3'

.....
/opt/uClinux/bfin-elf/bfin-elf/lib/libm.a(s_atan.o): In function `atan':
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/s_atan.c:169: undefined reference to `__muldf3'
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/s_atan.c:170: undefined reference to `__muldf3'
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/gcc-4.3/newlib/libm/math/s_atan.c:172: undefined reference to `__muldf3'
william pagnon
  • 335
  • 3
  • 16

3 Answers3

1

Add -lgcc. You need the functions to compare, add and multiply C double type values, respectively, __eqdf2, __adddf3 and __muldf3.

Usually, I'd recommend using the compiler driver (gcc) instead of linking directly with ld, even for firmware/kernel type outputs, because the former will take care of the necessary startup files and compiler runtime libraries.

chill
  • 16,470
  • 2
  • 40
  • 44
  • Hi, Thanks for the answer, I do generally use GCC to link as well unfortunately I haven't been able to do so with this application due to specific memory mapping. I've try few times before to just get GCC to compile and link but it didn't work. do you know how to add "the functions to compare, add and multiply C double type values, respectively, __eqdf2, __adddf3 and __muldf3" in directly the linker? the bfin elf ld linker do not accept -lgcc only -lg – william pagnon Nov 30 '11 at 01:24
  • @williampagnon, what do you mean by "does not accept -lgcc" ? Perhaps it cannot find it? It should be in `$gccdir/lib/gcc/$target/$version`. – chill Nov 30 '11 at 08:28
  • I thanks, I tried again and it works now, not sure why but I found the fix: I had: GNU ld version 2.17 /opt/uClinux/bfin-elf/bin/../bfin-elf/bin/ld.real: cannot find -lgcc. adding -L /opt/uClinux/bfin-elf/lib/gcc/bfin-elf/4.3.5/ library folder resolve the issue of -lgcc – william pagnon Dec 05 '11 at 07:20
0

Hi I think I know the problem, blackfin is not really compatible with the maths std lib. It is why in the VDSP version the maths functions are re implemented. To solve my problem, I did convert the VDSP maths lib to gcc and it compile fine now.

Thanks

william pagnon
  • 335
  • 3
  • 16
0

Actually I found a better answer,

blackfin does in fact support std math. I just had some library flag in the wrong order.

For the linker, use the following lib flag order and it should work:

/opt/uClinux/bfin-elf/bin/../bfin-elf/bin/ld.real' '-v' '-o' .... '-L' '/opt/uClinux/bfin-elf/lib/gcc/bfin-elf/4.3.5/' '-lgcc' '-L' '/opt/uClinux/bfin-elf/bfin-elf/lib' '-lbfdsp' '-lg' '-lm' '-lbffastfp' '-lc' 
william pagnon
  • 335
  • 3
  • 16