I am developing firmware for an embedded application on ARM Cortex-M in C++ with GCC 7.3.1 in C++14 mode. There's only 64k of flash available, and my binary wouldn't fit. Looking at the map file I see that there's a function called
__gcclibcxx_demangle_callback in the binary that takes up 27k flash space. I understand that this is related to C++ name demangling. The linker doesn't discard this symbol although I'm definitely not doing any name demangling in my code. I'm using STL here and there though. How can I eliminate this function to gain some flash space?
I've tried passing
-ffreestanding -fno-exceptions -nostartfiles -fno-rtti to the compiler and the linker. Passing
-nostdlib causes the linking to fail even if I pass
-lc -lg -lgcc -lstdc++.