4.5. Using $Super$$ and $Sub$$ to override symbol definitions
There are situations where an existing symbol cannot be modified because, for example, it is located in an external library or in ROM code.
Use the $Super$$ and $Sub$$ patterns to patch an existing symbol.
For example, to patch the definition of a function foo(), use $Super$$foo() and $Sub$$foo() as follows:
$Super$$fooIdentifies the original unpatched function foo(). Use this to call the original function directly.
$Sub$$fooIdentifies the new function that is called instead of the original function foo(). Use this to add processing before or after the original function.
Example 4.6 shows the legacy function foo() modified to result in a call to ExtraFunc() and a call to foo(). For more information, see the ARM ELF specification, aaelf.pdf, on the ARM website.
Example 4.6. Using $Super$$ and $Sub$$
extern void ExtraFunc(void);
extern void $Super$$foo(void):
/* this function is called instead of the original foo() */
void $Sub$$foo(void)
{
ExtraFunc(); /* does some extra setup work */
$Super$$foo(); /* calls the original foo() function */
}