In a C / C ++ open source project, I use gcc-arm-embedded (currently the most recent 4.9-2015-q2 ).
For some reason, I should avoid using some functions, for example, some of stdio et cetera (I don't want to use redirection or half-hunting).
In addition, I use FreeRtos with heap_4.c and had, for example, malloc()redirected directly to the pvPortMalloc()following:
void* malloc(size_t s) {
return pvPortMalloc(s);
}
Therefore, I do not want to have any parts of the toolchain management code inside my binary.
Now there are some situations like the developer of my team means to use, for example. printf(), which indirectly refers to _malloc_r()(and a few more), and itβs actually quite difficult to figure out what it refers to, and so where to fix it.
(Usage printf()is just an example. In my project, I have a custom printf () implementation that outputs directly to uart without using stdio. But there are other cases, for example, the info demangeling type, ...)
I currently have a situation where my project (which contains about 200 c and C ++ source files) is compiled without a link in _malloc_r()any way - while I am creating with gcc 4.8 .
But when creating gcc 4.9, I see unwanted links to _malloc_ra few more.
, ?
2015-07-20:
- , : gcc 4.9
_malloc_r . - , , .
, __gnu_cxx::__snprintf_lite(), iostream, . __gnu_cxx::__snprintf_lite() gcc stl (, __throw_out_of_range_fmt()). (, std::map). iostream , __gnu_cxx::__snprintf_lite(), ( vsnprintf):
namespace __gnu_cxx {
int __snprintf_lite(char* buf, size_t bufsize, const char* fmt, va_list ap) {
return vsnprintf(buf, bufsize, fmt, ap);
}
}
, gcc-4.9 (, src/gcc/libstdc++-v3/src/c++11/snprintf_lite.cc).