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