I'm experiencing the problem mentioned in the FAQ number 3000668:
Program Built with --gc-sections Option Does Not Run in GCC Project | Renesas Customer Hub
This bug is easily reproducible just by creating a new GCC project for the microcontroller R5F5671EHxFB with C++ and FreeRTOS.
By default, the compiler option --gc-sections is beeing enabled. If you disable it, the code works as expected.
--gc-sections
The program is breaking inside 'vTaskStartScheduler', when it tries to call some static privileged fuctions.
I've tried to add KEEP to the .ctors and .dtors sections in the linker file as mentioned here: 8.3.7 Gc-sections Option (microchip.com), but it does not solve the problem. There must be something else missconfigured.
I do not want to disable this option, because it reduces the size of the final binary file.
Can you check what's the cause of the failure?