6.7 Use of $Super$$ and $Sub$$ to patch symbol definitions
There are special patterns you can use for situations where an existing symbol cannot be modified.
An existing symbol cannot be modified, for example, if it is located in an external library
or in ROM code. In such cases you can use the
$Sub$$ patterns to patch an existing symbol.
To patch the definition of the function
Identifies the original unpatched function
foo(). Use this to call
the original function directly.
Identifies the new function that is called instead of the original function
foo(). Use this to add processing before or after the original
$Super$$ mechanism only works at static
$Super$$ references cannot be imported or exported into the
dynamic symbol table.
The following example shows how to use
$Sub$$ to insert a call to the function
ExtraFunc() before the call to the legacy function
extern void ExtraFunc(void);
extern void $Super$$foo(void):
/* this function is called instead of the original foo() */
ExtraFunc(); /* does some extra setup work */
$Super$$foo(); /* calls the original foo() function */
/* To avoid calling the original foo() function
* omit the $Super$$foo(); function call.