2

I'm writing bare-metal microcontroller code and want to use simple math function from <math.h> like sqrtf(), but found impure_data in symbol list eats 0x428 bytes, from lib_a-impure.o.

It turns out that reentrant code is being linked in(according to this), how to avoid this behavior?

I'm using riscv64-unknown-elf toolchain, seems like it does not have newlib-nano. What else can I do? Some complier flag maybe?

1 Answers1

1

I found answer from this post.

Using -fno-math-errno can eliminate impure_data, and sqrtf() will become a single riscv instruction fsqrt.s instead of __ieee754_sqrtf subroutine.

Using xpack-riscv-none-embed toolchain (old GNU MCU Eclipse RISC-V Embedded GCC) with -specs=nano.specs will still have impure_data, but much smaller(0x428 -> 0x60 in my case, sqrtf/__ieee754_sqrtf are also smaller)