all.
I want to link a library which calls malloc() function.
However, my target environment is different one and
malloc() is supplied as inline-function.
How can I make the library’s call to malloc() direct to
my target environment’s malloc() routine?
Is it any way to change the exported function name? If so
I can code my_malloc() first and export it as malloc() and link
the library to that one:
#include <my_environment.h> // malloc() is inline function declared there
void my_malloc (void) {
malloc (void);
}
More specifically,
the library is one from linux distro so it depends on libc.
But my environment is embedded one and has no libc library and malloc(), free(), … are custom-implemented. Some are inline functions and some are library functions.
The GNU linker (ld) supports a
--wrap=functionnameparameter. I’ll simply quote the documentation from the man page as it includes an example which should do exactly what you need: