对于那些打不开链接的人,直接看这里:
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 $Super$$ and $Sub$$ patterns to patch an existing symbol.
To patch the definition of the function foo():
$Super$$foo
Identifies the original unpatched function foo(). Use this to call the original function directly.
$Sub$$foo
Identifies the new function that is called instead of the original function foo(). Use this to add processing before or after the original function.
Example
The following example shows how to use $Super$$ and $Sub$$ to insert a call to the function ExtraFunc() before the call to the legacy function foo().
因为MDK提供了$Sub$和$$Super$$方法,对于公共函数,外界是可以强行对其进行替换的,
为了防止内部逻辑被篡改,给关键的静态函数再套一层公共函数是正确的做法——这样内部
其它静态函数就直接调用静态版本,外部其它模块就可以直接调用公共版本——即便篡改,
也是坑外不坑内。
Use of $Super$$ and $Sub$$ to patch symbol definitions
http://infocenter.arm.com/help/i ... e1362065967698.html
对于那些打不开链接的人,直接看这里:
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 $Super$$ and $Sub$$ patterns to patch an existing symbol.
To patch the definition of the function foo():
$Super$$foo
Identifies the original unpatched function foo(). Use this to call the original function directly.
$Sub$$foo
Identifies the new function that is called instead of the original function foo(). Use this to add processing before or after the original function.
Example
The following example shows how to use $Super$$ and $Sub$$ to insert a call to the function ExtraFunc() before the call to the legacy function foo().
- 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 */
- /* To avoid calling the original foo() function
- * omit the $Super$foo(); function call.
- */
- }
复制代码一周热门 更多>