I have the following problem:
In some commercial project (ARM Cortex-M), we have pre-compiled libraries from a supplier.
The library contains code from different suppliers; some library functions use the standard malloc()
function call, while others use the memory allocator of the operating system (in the example below: os_malloc()
).
The malloc()
function is taken from the libc.a
standard library.
Both implementations seem to disturb each other. For this reason I'd like to replace the default malloc()
(and free()
) implementation by something like this:
void * malloc(uint32_t size)
{
return os_malloc(size);
}
void free(void * ptr)
{
os_free(ptr);
}
However, in this case I would have to remove the object file containing malloc()
and free()
from the libc.a
library file - what I also don't want to do.
Is there a possibility to tell the GNU linker not to take some symbol from a library if it is already defined outside the library?
... or a possibility to tell the linker not to take a certain object file from a library?
... or a possibility to do something like PROVIDE(malloc = os_malloc);
in the linker script although the symbol malloc
is defined in some library?
Thank you very much.