If you look into the retarget.c then you see the following snippet:
\\#if defined(TOOLCHAIN_GCC)
/* prevents the exception handling name demangling code getting pulled in */
\\#include "mbed_error.h"
namespace __gnu_cxx {
void __verbose_terminate_handler() {
error("Exception");
}
}
extern "C" WEAK void __cxa_pure_virtual(void);
extern "C" WEAK void __cxa_pure_virtual(void) {
exit(1);
}
\\#endif
and because you haven't defined TOOLCHAIN_GCC the demangle functions are pulled in. Put the TOOLCHAIN_GCC at the compilers symbols tab and you will see that your code is going from 56556 to 29644. (perhaps your figures are different because I'm using 4.8 with EB build libraries)
The following steps:
- Add TOOLCHAIN_GCC (and TOOLCHAIN_GCC_ARM) down to 29644 bytes
- If you turn on the no RTTI and no exceptions, it is going down to 20452 bytes.
- with "-fno-builtin" as compiler option, down to 20444
- With -Os down to 19544 bytes
- And with -flto (4.8 toolchain) 17636 bytes
So the image is 56556 -> 17636 (reduction > 68%) and with -O2: 18560 (reduction +/- 67%)
Ps.
LTO is working here because they don't use assembler files for the RTOS port.
That's why an imported project was going right, the symbol was transferred from Mbed into EB compilers symbols.
I could narrow this down that one project uses the abort() from libc in the new_handler() and the other the std::terminate().
Why? I don't know.
https://answers.launchpad.net/gcc-arm-embedded/+question/255714