2021-09-09 08:57 AM
I'm trying to migrate a project from HAL back to SPL as it's less of a haul than porting our code I have to integrate to HAL. The HAL program compiled but at some point during my porting process I'm now getting link errors ONLY for _fstat and _isatty, not any of the other functions defined in the assert.c
The assert.c is the same between a working SPL based project we have and the new one I'm creating, so nothing has changed there. If I implement _fstat in my main.c it still complains that it can't link.
Linker Error:
c:/program files (x86)/gnu arm embedded toolchain/10 2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: c:/program files (x86)/gnu arm embedded toolchain/10 2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libg_nano.a(lib_a-fstatr.o): in function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
I've also tried changing and linking against the soft-fp version of the library with no change.
From main.c:
#include <sys/stat.h>
int _fstat (int fd, struct stat* st)
{
memset (st, 0, sizeof(*st));
return _swistat (fd, st);
}
2021-09-09 11:05 AM
These are system calls. They should be in "syscalls.c" in your project somewhere, not in the newlib library. If you generate code with CubeMX, it will generate them.
2021-09-09 12:08 PM
Yes, they are in "syscalls.c" but the newlib nano links against their implementations. For some reason the linker isn't finding the definitions in the syscalls.c or even if I override them in my main.c (as they are declared as __attribute__(weak) to allow overriding in other code)
2024-02-23 12:54 AM
Still the same problem (but only with full optimization), using latest ARM GCC 13.2r1...