What is the role of syscalls.c file in GNU ARM(STM32 for instance) based projects? I found 2 ways of successfully building the project
Delete syscalls.c and include -specs=nosys.specs in the linker flags
Simply include syscalls.c
What is the fundamental difference between these two methods? What is the importance of system calls in a non-os environment like microcontroller? If it is used for implementing system-level functions used by printf, scanf, etc. then who is calling these function(because I am not using any of these functions in my code)?
Edit:- As an experimental step, I deleted syscalls.c and added -specs=nosys.specs to make the linker happy then I wrote a simple malloc program to check whether it is working or not. To my surprise, it is giving the expected output. How did the malloc function work without the _sbrk definition in syscalls.c? I checked the startup file but it has only a few functions like copying data from flash to SRAM during startup, zeroing out .bss section, etc. Can I assume that it has to do something with C Runtime Library? If so where is it located?
P.S - I am using System Workbench for STM32 & STM32F4Nucleo board for this particular example