iOS inline
转:http://www.blogfshare.com/ioss-static-inline.html
一般的函数调用都会通过call的方式来调用,这样让攻击很容易对一个函数做手脚,如果是以inline的方式编译的会,会把该函数的code拷贝到每次调用该函数的地方。而static会让生成的二进制文件中没有清晰的符号表,让逆向的人很难弄清楚逻辑。
下面我们来看看一个普通函数及其反汇编代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | int isValidate ( int id ) { if (id > 5 ) return 1 ; else return 0 ; } int main ( int argc , const char argv [ ] ) { int id = 3 ; int a = 1 ,b = 2 ,c = 3 ; if ( !isValidate (id ) ) return 0 ; a = b + c ; if ( !isValidate (id ) ) return 0 ; c = a / 2 b ; if ( !isValidate (id ) ) return 0 ; b = c / a * 2 ; return 1 ; } |
编译,反汇编结果如下:
这样可以很明显的看到isValidate的调用,而且很容易使用断点+commands的方法让其始终返回1.
下面使用inline的方式来编译:
1 | int isValidate ( int id ) attribute ( (always_inline ) ) ; |
编译,反汇编结果如下:
在每次调用的时候都会把代码拷贝一次。
再来看看static inline的方式来编译的反汇编代码:
1 | static int isValidate ( int id ) attribute ( (always_inline ) ) ; |
现在没有符号表了。
还没有评论,来说两句吧...