Undefined reference to __aeabi_ddiv and friends - creation without stdlib, but with -mfloat-abi = hard

I am trying to build a project for Cortex-M4F. The chip has FPU, so I build with -mfpu=fpv4-sp-d16 -mfloat-abi=hard , and I don't use libraries to save space, so I do -nostdlib -fno-builtin .

Now I want to use floating point operations, but in doing so I get a linker error:

 led1642gw_gain.c:(.text.led_calculateGain+0xc): undefined reference to `__aeabi_f2d' led1642gw_gain.c:(.text.led_calculateGain+0x24): undefined reference to `__aeabi_ddiv' led1642gw_gain.c:(.text.led_calculateGain+0x36): undefined reference to `__aeabi_dsub' led1642gw_gain.c:(.text.led_calculateGain+0x48): undefined reference to `__aeabi_ddiv' led1642gw_gain.c:(.text.led_calculateGain+0x54): undefined reference to `__aeabi_d2f' led1642gw_gain.c:(.text.led_calculateGain+0x9e): undefined reference to `__aeabi_f2d' led1642gw_gain.c:(.text.led_calculateGain+0xb6): undefined reference to `__aeabi_ddiv' led1642gw_gain.c:(.text.led_calculateGain+0xc8): undefined reference to `__aeabi_dsub' led1642gw_gain.c:(.text.led_calculateGain+0xda): undefined reference to `__aeabi_ddiv' led1642gw_gain.c:(.text.led_calculateGain+0xe6): undefined reference to `__aeabi_d2f' led1642gw_gain.c:(.text.led_calculateGain+0x10c): undefined reference to `__aeabi_f2d' 

Why? If I understand correctly, he should not rely on library functions, but for this he needs to use his own FPU instructions for ARM.

+5
source share
1 answer

Your kernel supports single precision floating point commands, however your code works with double precision floating point.

You may notice that all missing __aeabi things have a "d" (as in double).

If your code has floating point literals, then they are considered double by the C standard. You can force them into the range with one precision by adding f or f to the end of the literal.

2.13.3 Floating literals . A flexible literal type is double unless a suffix is ​​explicitly specified. The suffixes f and F specify a float ...

+4
source

Source: https://habr.com/ru/post/1205196/


All Articles