I have an IAR STM32 project where I am need to wrap a library function with some custom logic. I do not have the ability to recompile the library itself, so what I would like to do is create a function libfunction_shim that calls into the original libfunction. Using the --redirect linker option (--redirect libfunction=libfunction_shim), I can redirect calls to the original function to the shim, including calls inside the library itself. However, I need to call the original function from the shim.
If I add another redirect (--redirect libfunction_original=libfunction), it ends up redirecting libfunction_original to libfunction_shim, rather than the original libfunction. I've tried reordering the redirects, but it does the same thing regardless of order.
The linker log demonstrates this:
Symbol Redirected to Reason
------------- ------ ------
...
libfunction libfunction_shim command line
libfunction_original libfunction_shim command line
What I would like this:
Symbol Redirected to Reason
------------- ------ ------
...
libfunction libfunction_shim command line
libfunction_original libfunction command line
Is it possible to do this using the linker?
libfunction_shimat user code directly, or rename function using the preprocessor? - user694733