Using LD, the GNU linker - Options
ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html--wrap symbol
Use a wrapper function for symbol. Any undefined reference to
symbol will be resolved to wrap_symbol. Any
undefined reference to real_symbol will be resolved to
symbol.This can be used to provide a wrapper for a system function. The
wrapper function should be called wrap_symbol. If it
wishes to call the system function, it should call
real_symbol.Here is a trivial example: