I am working on a syscall implementation for a PowerPc. I have tested some gcc functions and they all seem to work (e.g. sqrt sin cos pow printf malloc...)
I recently realised a problem with the printf. it works fine as long as I print some integer/char but when I try to printf %f/lf to print float/double the program crashes. (it seems to be executing somewhere it should not be)
I have checked the makefile, it uses:
# use soft float
CFLAGS += -msoft-float
and when making the program I can see many nof (no float) libraries being linked.
gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/bin/../lib/gcc/powerpc-eabi/4.3.3/../../../../powerpc-eabi/lib/nof\libm.a)lib_a-s_sin.o
I also know that I hav开发者_如何学Goe enough space in stack/heap so that should not be a problem. It there still a reason why printf should crash when printing float?
Your newlib is probably built without support for floating-point IO. This is fairly common for embedded systems as it saves a lot of code space. You can probably rebuild newlib to support floating-point IO. I think the configure options are --enable-newlib-io-float
and --enable-newlib-io-long-double
. You can probably find out for sure by running ./configure --help
.
精彩评论