objc反汇编分析__strong和__weak
如题所说反汇编看__strong和__weak的真实样子,代码列举自然多,篇幅长不利于阅读,我就先搬出结论,后面是分析。
在NON-ARC环境,__strong和__weak不起作用。相反在ARC环境中会自动生成许多代码,__strong和__weak将生成指针引用这样的C++类,它们会在离开生命周期作用的范围(可以推广到作为实例的成员的情况)之前析构。而ARC中指针默认带__strong属性,也就是__strong完成了auto reference count。它们的伪代码如下:
- template<typename _Tptr>
- struct __weak
- {
- _Tptr p;
- ~__weak()
- {
- destoryWeak(&p);
- }
- __weak()
- {
- p = initWeak(&p, nil);
- }
- __weak(id newObj)
- {
- p = initWeak(&p, newObj);
- }
- __weak(__strong<_Tptr>& other)
- {
- p = storeWeak(&p, *other);
- }
- void operator= (__strong<_Tptr>& other)
- {
- p = storeWeak(&p, *other);
- }
- void operator= (__weak<_Tptr>& other)
- {
- id newObj = *other;
- p = storeWeak(&p, newObj);
- [newObj release];
- }
- id operator*()
- {
- return loadWeakRetained(&p);
- }
- };
- template<typename _Tptr>
- struct __strong
- {
- _Tptr p;
- ~__strong()
- {
- storeStrong(&p, nil);
- }
- __strong()
- {
- p = nil;
- }
- __strong(id newObj)
- {
- p = [newObj retain];
- }
- __strong(__strong<_Tptr>& other)
- {
- storeStrong(&p, *other);
- }
- void operator= (__strong<_Tptr>& other)
- {
- storeStrong(&p, *other);
- }
- void operator= (__weak<_Tptr>& other)
- {
- id newObj = *other;
- storeStrong(&p, newObj);
- [newObj release];
- }
- id operator* ()
- {
- return (id)p;
- }
- };
- template<typename _Tptr>
- id msgSend(__strong<_Tptr>& strong, SEL sel, ...)
- {
- return msgSend(*strong, sel, ...);
- }
- template<typename _Tptr>
- id msgSend(__weak<_Tptr>& weak, SEL sel, ...)
- {
- id receiver = *weak;
- id res = msgSend(*weak, sel, ...);
- [receiver release];
- return res;
- }
- void storeStrong(id* loc, id newObj)
- {
- [*loc release];
- *loc = [newObj retain];
- }
下面就是分析,代码和汇编代码列举,对比。
我们先请出我们的嘉宾,还是a,b,c。
a 是全局大爷,无视HP值,与程序一样长寿。
b 是tagged幽灵,它真切地像对象一样反应,而当你想真实看清它指向的那块地却找不到影,但它又像真的存在。
c 是临记,在堆中芸芸众生之一,在戏份过后,就会因为HP消耗而领便当。
我们为它们分别安排带__strong的sa,sb,sc,以及__weak的wa,wb,wc。
它们之间通过相互赋值,赋不同的值,抑或它们调用引用,它们倾情上演__strong&__weak,not Tom & Jerry,敬请大家期待,现在隆重开场。
先来看定义,想一想整个运作过程:
- -(void)testNSString2
- {
- NSString* a = @"abc";
- NSString* b = [NSString stringWithUTF8String:"abc"];
- NSString* c = [@"ab" stringByAppendingString:@"c"];
- __strong id sa = a;
- __strong id sb = b;
- __strong id sc = c;
- __weak id wa = a;
- __weak id wb = sb;
- __weak id wc = c;
- sc = wc;
- wc = sb;
- [wc isEqualToString:sc];
- }
下面开始反汇编对比。在NON-ARC环境中,objc指针和普通c指针一样进行起无差别格斗,指针你来我往直接赋值指向,__strong和__weak不起作用。
- 0x1060580d0 <+>: pushq %rbp
- 0x1060580d1 <+>: movq %rsp, %rbp
- 0x1060580d4 <+>: subq $0x70, %rsp
- 0x1060580d8 <+>: leaq 0x1d90(%rip), %rdx ; "abc"
- 0x1060580df <+>: leaq 0x1fda(%rip), %rax ; @"abc"
- 0x1060580e6 <+>: movq %rdi, -0x8(%rbp)
- 0x1060580ea <+>: movq %rsi, -0x10(%rbp)
- -> 0x1060580ee <+>: movq %rax, -0x18(%rbp)
- 0x1060580f2 <+>: movq 0x2e77(%rip), %rax ; (void *)0x000000010636eb20: NSString
- 0x1060580f9 <+>: movq 0x2de8(%rip), %rsi ; "stringWithUTF8String:"
- 0x106058100 <+>: movq %rax, %rdi
- 0x106058103 <+>: callq 0x106058a08 ; symbol stub for: objc_msgSend
- 0x106058108 <+>: leaq 0x1fd1(%rip), %rdx ; @"ab"
- 0x10605810f <+>: leaq 0x1fea(%rip), %rsi ; @"'c'"
- 0x106058116 <+>: movq %rax, -0x20(%rbp)
- 0x10605811a <+>: movq 0x2dcf(%rip), %rax ; "stringByAppendingString:"
- 0x106058121 <+>: movq %rdx, %rdi
- 0x106058124 <+>: movq %rsi, -0x60(%rbp)
- 0x106058128 <+>: movq %rax, %rsi
- 0x10605812b <+>: movq -0x60(%rbp), %rdx
- 0x10605812f <+>: callq 0x106058a08 ; symbol stub for: objc_msgSend
- 0x106058134 <+>: movq %rax, -0x28(%rbp)
- 0x106058138 <+>: movq -0x18(%rbp), %rax
- 0x10605813c <+>: movq %rax, -0x30(%rbp)
- 0x106058140 <+>: movq -0x20(%rbp), %rax
- 0x106058144 <+>: movq %rax, -0x38(%rbp)
- 0x106058148 <+>: movq -0x28(%rbp), %rax
- 0x10605814c <+>: movq %rax, -0x40(%rbp)
- 0x106058150 <+>: movq -0x18(%rbp), %rax
- 0x106058154 <+>: movq %rax, -0x48(%rbp)
- 0x106058158 <+>: movq -0x38(%rbp), %rax
- 0x10605815c <+>: movq %rax, -0x50(%rbp)
- 0x106058160 <+>: movq -0x28(%rbp), %rax
- 0x106058164 <+>: movq %rax, -0x58(%rbp)
- 0x106058168 <+>: movq -0x58(%rbp), %rax
- 0x10605816c <+>: movq %rax, -0x40(%rbp)
- 0x106058170 <+>: movq -0x38(%rbp), %rax
- 0x106058174 <+>: movq %rax, -0x58(%rbp)
- 0x106058178 <+>: movq -0x58(%rbp), %rdi
- 0x10605817c <+>: movq -0x40(%rbp), %rax
- 0x106058180 <+>: movq 0x2d81(%rip), %rsi ; "isEqualToString:"
- 0x106058187 <+>: movq %rax, %rdx
- 0x10605818a <+>: callq 0x106058a08 ; symbol stub for: objc_msgSend
- 0x10605818f <+>: movb %al, -0x61(%rbp)
- 0x106058192 <+>: addq $0x70, %rsp
- 0x106058196 <+>: popq %rbp
- 0x106058197 <+>: retq
接着分析另一种环境。
在ARC环境中,战斗全面升级,各种华丽招式层出不穷,拳来脚往眼花獠乱。
先来看a,b,c。虽然它们没有表明它们是__strong部落,还是__weak联盟,但从它们扭着大pp的步姿,就知道它们骨子里透着__strong的味道。初始值时都加了一招objc_retain。还有一招objc_retainAutoreleaseReturnValue,就如其名对autorelease过的返回值retain。
恭喜你发现了__strong<NSString*> a, b, c!!!
NSString* a = @"abc";
NSString* b = [NSString stringWithUTF8String:"abc"];
NSString* c = [@"ab" stringByAppendingString:@"c"];
- -> 0x103658933 <+>: leaq 0x27e6(%rip), %rdi ; @"abc"
- 0x10365893a <+>: movq 0x26f7(%rip), %rsi ; (void *)0x0000000103b6cd00: objc_retain
- 0x103658941 <+>: movq %rsi, -0x80(%rbp)
- 0x103658945 <+>: callq *%rsi
- 0x103658947 <+>: movq %rax, -0x18(%rbp) ; // NSString* a = @"abc";
- 0x10365894b <+>: movq 0x3656(%rip), %rdi ; (void *)0x0000000103970b20: NSString
- 0x103658952 <+>: movq 0x35c7(%rip), %rsi ; "stringWithUTF8String:"
- 0x103658959 <+>: leaq 0x2507(%rip), %rdx ; "abc"
- 0x103658960 <+>: movq 0x26c1(%rip), %rax ; (void *)0x0000000103b6f800: objc_msgSend
- 0x103658967 <+>: movq %rax, -0x88(%rbp)
- 0x10365896e <+>: callq *%rax
- 0x103658970 <+>: movq %rax, %rdi
- 0x103658973 <+>: callq 0x103659896 ; symbol stub for: objc_retainAutoreleasedReturnValue
- 0x103658978 <+>: movq %rax, -0x20(%rbp) ; // NSString* b = [NSString stringWithUTF8String:"abc"];
- 0x10365897c <+>: movq 0x35a5(%rip), %rsi ; "stringByAppendingString:"
- 0x103658983 <+>: leaq 0x27b6(%rip), %rdi ; @"ab"
- 0x10365898a <+>: leaq 0x27cf(%rip), %rdx ; @"'c'"
- 0x103658991 <+>: movq -0x88(%rbp), %rax
- 0x103658998 <+>: callq *%rax
- 0x10365899a <+>: movq %rax, %rdi
- 0x10365899d <+>: callq 0x103659896 ; symbol stub for: objc_retainAutoreleasedReturnValue
- 0x1036589a2 <+>: movq %rax, -0x28(%rbp) ; // NSString* c = [@"ab" stringByAppendingString:@"c"];
毫无悬念__strong三人组sa,sb,sc,在初始值也都使出了objc_retain。
__strong id sa = a;
__strong id sb = b;
__strong id sc = c;
- 0x1036589a6 <+>: movq -0x18(%rbp), %rdi
- 0x1036589aa <+>: movq -0x80(%rbp), %rax
- 0x1036589ae <+>: callq *%rax ; objc_retain
- 0x1036589b0 <+>: movq %rax, -0x30(%rbp) ; // __strong id sa = a;
- 0x1036589b4 <+>: movq -0x20(%rbp), %rdi
- 0x1036589b8 <+>: movq -0x80(%rbp), %rax
- 0x1036589bc <+>: callq *%rax
- 0x1036589be <+>: movq %rax, -0x38(%rbp) ; // __strong id sb = b;
- 0x1036589c2 <+>: movq -0x28(%rbp), %rdi
- 0x1036589c6 <+>: movq -0x80(%rbp), %rax
- 0x1036589ca <+>: callq *%rax
- 0x1036589cc <+>: movq %rax, -0x40(%rbp) ; // __strong id sc = c;
同是__strong阵营的a,b,c和sa,sb,sc,它们交手赋值,它们使出了objc_storeStrong。在它们掌心和掌心对上的那一刻,a已经将旧时的它release掉,同时用写轮眼retain了sa。
a = sa;
b = sb;
c = sc;
- 0x1036589d0 <+>: movq -0x30(%rbp), %rsi
- 0x1036589d4 <+>: leaq -0x18(%rbp), %rdi
- 0x1036589d8 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x1036589dd <+>: movq -0x38(%rbp), %rsi
- 0x1036589e1 <+>: leaq -0x20(%rbp), %rdi
- 0x1036589e5 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x1036589ea <+>: movq -0x40(%rbp), %rsi
- 0x1036589ee <+>: leaq -0x28(%rbp), %rdi
- 0x1036589f2 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
不好,__strong遭遇上__weak! __weak的wa,wb,wc纷纷要上标记使出了objc_initWeak。它们伪装成了a,sb,c。就是说它们存储的地址一样,*(int64*)&a == *(int64*)&wa,但是它们的引用操作却不一样。
__weak id wa = a;
__weak id wb = sb;
__weak id wc = c;
- 0x1036589f7 <+>: movq -0x18(%rbp), %rsi
- 0x1036589fb <+>: leaq -0x48(%rbp), %rdi
- 0x1036589ff <+>: callq 0x103659866 ; symbol stub for: objc_initWeak
- 0x103658a04 <+>: movq -0x38(%rbp), %rsi
- 0x103658a08 <+>: leaq -0x50(%rbp), %rdi
- 0x103658a0c <+>: movq %rax, -0x90(%rbp)
- 0x103658a13 <+>: callq 0x103659866 ; symbol stub for: objc_initWeak
- 0x103658a18 <+>: movq -0x28(%rbp), %rsi
- 0x103658a1c <+>: leaq -0x58(%rbp), %rdx
- 0x103658a20 <+>: movq %rdx, %rdi
- 0x103658a23 <+>: movq %rax, -0x98(%rbp)
- 0x103658a2a <+>: movq %rdx, -0xa0(%rbp)
- 0x103658a31 <+>: callq 0x103659866 ; symbol stub for: objc_initWeak
不要转台不要收快递交水费,__strong还招啦。__strong的sc对__weak的wc不可以直接使出retain,而必须让__weak先使用objc_loadWeakRetained。得手后的sc马上objc_release旧型态,才能对wc伪装的实体进行retain。
相反__weak的wc对__strong的sb出手则可以直接使出一招objc_storeWeak,然后伪装成了sb。
sc = wc;
wc = sb;
- 0x103658a36 <+>: movq -0xa0(%rbp), %rdi
- 0x103658a3d <+>: movq %rax, -0xa8(%rbp)
- 0x103658a44 <+>: callq 0x10365986c ; symbol stub for: objc_loadWeakRetained
- 0x103658a49 <+>: movq -0x40(%rbp), %rdi
- 0x103658a4d <+>: movq %rax, -0x40(%rbp)
- 0x103658a51 <+>: movq 0x25d8(%rip), %rax ; (void *)0x0000000103b6cd70: objc_release
- 0x103658a58 <+>: callq *%rax
- 0x103658a5a <+>: movq -0x38(%rbp), %rsi
- 0x103658a5e <+>: movq -0xa0(%rbp), %rdi
- 0x103658a65 <+>: callq 0x1036598a8 ; symbol stub for: objc_storeWeak
wc要用它刚获得到的新伪装型态,对sc还招,wc要使用sb的技能-isEqualToString:,终究变化系不能直接使出强化系,必须通过objc_loadWeakRetained转系,然后大喝一声,使出了崩天塌地的一招-isEqualToString:,一掌拍向sc。
sc施展出凌波微步,想避开wc,但还是中了掌, wc返回了YES。最后wc还要用objc_release收功散气,脱离sb型态。
[wc isEqualToString:sc];
- 0x103658a6a <+>: movq -0xa0(%rbp), %rdi
- 0x103658a71 <+>: movq %rax, -0xb0(%rbp)
- 0x103658a78 <+>: callq 0x10365986c ; symbol stub for: objc_loadWeakRetained
- 0x103658a7d <+>: movq %rax, %rdx
- 0x103658a80 <+>: movq -0x40(%rbp), %rsi
- 0x103658a84 <+>: movq 0x34b5(%rip), %rdi ; "isEqualToString:"
- 0x103658a8b <+>: movq %rdi, -0xb8(%rbp)
- 0x103658a92 <+>: movq %rax, %rdi
- 0x103658a95 <+>: movq -0xb8(%rbp), %rax
- 0x103658a9c <+>: movq %rsi, -0xc0(%rbp)
- 0x103658aa3 <+>: movq %rax, %rsi
- 0x103658aa6 <+>: movq -0xc0(%rbp), %rcx
- 0x103658aad <+>: movq %rdx, -0xc8(%rbp)
- 0x103658ab4 <+>: movq %rcx, %rdx
- 0x103658ab7 <+>: movq -0x88(%rbp), %r8
- 0x103658abe <+>: callq *%r8
- 0x103658ac1 <+>: movb %al, -0xc9(%rbp)
- 0x103658ac7 <+>: jmp 0x103658acc ; <+428> at ViewController.m:100
- 0x103658acc <+>: movq 0x255d(%rip), %rax ; (void *)0x0000000103b6cd70: objc_release
- 0x103658ad3 <+>: movq -0xc8(%rbp), %rdi
- 0x103658ada <+>: callq *%rax
对于没有autorelease过的objc对象,__strong是不会使出objc_retain,
__strong NSString* sx = [[NSString alloc] initWithString:@"abc"];
- 0x103658adc <+>: movq 0x34c5(%rip), %rdi ; (void *)0x0000000103970b20: NSString
- 0x103658ae3 <+>: movq 0x345e(%rip), %rsi ; "alloc"
- 0x103658aea <+>: movq 0x2537(%rip), %rax ; (void *)0x0000000103b6f800: objc_msgSend
- 0x103658af1 <+>: callq *%rax
- 0x103658af3 <+>: movq %rax, -0xd8(%rbp)
- 0x103658afa <+>: jmp 0x103658aff ; <+479> at ViewController.m:102
- 0x103658aff <+>: movq 0x344a(%rip), %rsi ; "initWithString:"
- 0x103658b06 <+>: leaq 0x2613(%rip), %rdx ; @"abc"
- 0x103658b0d <+>: movq 0x2514(%rip), %rax ; (void *)0x0000000103b6f800: objc_msgSend
- 0x103658b14 <+>: movq -0xd8(%rbp), %rdi
- 0x103658b1b <+>: callq *%rax
- 0x103658b1d <+>: movq %rax, -0xe0(%rbp)
- 0x103658b24 <+>: jmp 0x103658b29 ; <+521> at ViewController.m:102
- 0x103658b29 <+>: movq -0xe0(%rbp), %rax
- 0x103658b30 <+>: movq %rax, -0x70(%rbp)
NSString* x = [[NSString alloc] initWithString:@"abc"];
- 0x103658b34 <+>: movq 0x346d(%rip), %rdi ; (void *)0x0000000103970b20: NSString
- 0x103658b3b <+>: movq 0x3406(%rip), %rsi ; "alloc"
- 0x103658b42 <+>: movq 0x24df(%rip), %rcx ; (void *)0x0000000103b6f800: objc_msgSend
- 0x103658b49 <+>: callq *%rcx
- 0x103658b4b <+>: movq %rax, -0xe8(%rbp)
- 0x103658b52 <+>: jmp 0x103658b57 ; <+567> at ViewController.m:103
- 0x103658b57 <+>: movq 0x33f2(%rip), %rsi ; "initWithString:"
- 0x103658b5e <+>: leaq 0x25bb(%rip), %rdx ; @"abc"
- 0x103658b65 <+>: movq 0x24bc(%rip), %rax ; (void *)0x0000000103b6f800: objc_msgSend
- 0x103658b6c <+>: movq -0xe8(%rbp), %rdi
- 0x103658b73 <+>: callq *%rax
- 0x103658b75 <+>: movq %rax, -0xf0(%rbp)
- 0x103658b7c <+>: jmp 0x103658b81 ; <+609> at ViewController.m:103
- 0x103658b89 <+>: movq -0xf0(%rbp), %rdx
- 0x103658b90 <+>: movq %rdx, -0x78(%rbp)
在谢幕时,它们离开作用范围,(它们是__strong<Tptr>和__weak<Tptr>,而不是它们指向的实例对象。)它们作为c++对象析构了。析构请参看上面我给出的伪代码。
pointers destructures
- 0x103658b81 <+>: xorl %eax, %eax
- 0x103658b83 <+>: movl %eax, %esi
- 0x103658b85 <+>: leaq -0x78(%rbp), %rcx
- 0x103658b94 <+>: movq %rcx, %rdi
- 0x103658b97 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658b9c <+>: xorl %eax, %eax
- 0x103658b9e <+>: movl %eax, %esi
- 0x103658ba0 <+>: leaq -0x70(%rbp), %rcx
- 0x103658ba4 <+>: movq %rcx, %rdi
- 0x103658ba7 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658bac <+>: leaq -0x58(%rbp), %rdi
- 0x103658bb0 <+>: callq 0x103659860 ; symbol stub for: objc_destroyWeak
- 0x103658bb5 <+>: leaq -0x50(%rbp), %rdi
- 0x103658bb9 <+>: callq 0x103659860 ; symbol stub for: objc_destroyWeak
- 0x103658bbe <+>: leaq -0x48(%rbp), %rdi
- 0x103658bc2 <+>: callq 0x103659860 ; symbol stub for: objc_destroyWeak
- 0x103658bc7 <+>: leaq -0x40(%rbp), %rdi
- 0x103658bcb <+>: xorl %eax, %eax
- 0x103658bcd <+>: movl %eax, %esi
- 0x103658bcf <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658bd4 <+>: leaq -0x38(%rbp), %rdi
- 0x103658bd8 <+>: xorl %eax, %eax
- 0x103658bda <+>: movl %eax, %esi
- 0x103658bdc <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658be1 <+>: leaq -0x30(%rbp), %rdi
- 0x103658be5 <+>: xorl %eax, %eax
- 0x103658be7 <+>: movl %eax, %esi
- 0x103658be9 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658bee <+>: xorl %eax, %eax
- 0x103658bf0 <+>: movl %eax, %esi
- 0x103658bf2 <+>: leaq -0x28(%rbp), %rcx
- 0x103658bf6 <+>: movq %rcx, %rdi
- 0x103658bf9 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658bfe <+>: xorl %eax, %eax
- 0x103658c00 <+>: movl %eax, %esi
- 0x103658c02 <+>: leaq -0x20(%rbp), %rcx
- 0x103658c06 <+>: movq %rcx, %rdi
- 0x103658c09 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658c0e <+>: xorl %eax, %eax
- 0x103658c10 <+>: movl %eax, %esi
- 0x103658c12 <+>: leaq -0x18(%rbp), %rcx
- 0x103658c16 <+>: movq %rcx, %rdi
- 0x103658c19 <+>: callq 0x1036598a2 ; symbol stub for: objc_storeStrong
- 0x103658c1e <+>: addq $0xf0, %rsp
- 0x103658c25 <+>: popq %rbp
- 0x103658c26 <+>: retq
花絮送出__weak和__weak的NG片段,wb被逼使用objc_loadWeakRetained,wa才能对其真身使出objc_storeWeak,然后wb使用objc_release结束真身型态。__weak作为operator=的操作数或msgSend的接收者时,都必须进行loadWeakRetained,结束之时马上release。
wa = wb;
- 0x10c47bb51 <+>: leaq -0x50(%rbp), %rdi
- 0x10c47bb60 <+>: callq 0x10c47c86c ; symbol stub for: objc_loadWeakRetained
- 0x10c47bb65 <+>: leaq -0x48(%rbp), %rdi
- 0x10c47bb69 <+>: movq %rax, %rsi
- 0x10c47bb6c <+>: movq %rax, -0xf8(%rbp)
- 0x10c47bb73 <+>: callq 0x10c47c8a8 ; symbol stub for: objc_storeWeak
- 0x10c47bb78 <+>: movq -0xf8(%rbp), %rdi
- 0x10c47bb7f <+>: movq %rax, -0x100(%rbp)
- 0x10c47bb86 <+>: callq 0x10c47c87e ; symbol stub for: objc_release
最后多谢大家观看本期节目,希望看得开心无聊得欢乐,多谢收看。
objc反汇编分析__strong和__weak的更多相关文章
- objc反汇编分析,block函数块为何物?
上一篇向大家介绍了__block变量的反汇编和它的伪代码,本篇函数块block,通常定义成原型(^){},它在反汇编中是什么东西. 我们先定义将要反汇编的例子,为减少篇幅例子采用non-arc环境. ...
- objc反汇编分析,手工逆向libsystem_blocks.dylib
上一篇<block函数块为何物?>介绍了在函数中定义的block函数块的反汇编实现,我在文中再三指出__block变量和block函数块自始还都是stack-based的,还不完全适合在离 ...
- 反汇编分析objc函数枢纽objc_msgSend
在分析objc_msgSend之前,先来搞清楚另一个问题. 函数是什么?可能会答 void foo(void) {} 像这样就是一个函数.或者函数包括函数原型和函数定义,是一段执行某样功能的机器代码. ...
- Linux下简单C语言小程序的反汇编分析
韩洋原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 写在开始,本文为因为参加MOO ...
- 反汇编分析NSString,你印象中的NSString是这样吗
我们先来定义三个NSString -(void) testNSString { NSString* a = @"abc"; NSString* b = [NSString stri ...
- mingw32 exception在sjlj与dwarf差别-反汇编分析
sjlj (setjump/longjump)与dwarf-2为mingw32两种异常处理模型的实现.sjlj有着开销,而随linux发行的mingw32开发库包都是用sjlj版编译的,而Qt却采用d ...
- 实验4 汇编应用编程和c语言程序反汇编分析
1. 实验任务1 教材「实验9 根据材料编程」(P187-189)编程:在屏幕中间分别显示绿色.绿底红色.白底蓝色的字符串'welcome to masm!'. 解题思路:根据学习的知识,我知道该页在 ...
- 反汇编分析__stdcall和__cdecl的异同
C++代码如下:.h头文件 #pragma once#ifdef DLLTestAPI#else#define DLLTestAPI _declspec(dllimport)#endifint DLL ...
- 反汇编分析C++代码
编译环境:Windows 10 + VS2015 1.问题引入 在Win32环境下,CPU小端模式,参数用栈来传递,写出输出结果. 代码如下: int main() { long long a = 1 ...
随机推荐
- axios reponse请求拦截以及token过期跳转问题
前两天项目中遇到了token拦截,需要在请求的header头里放置token,需要用到response拦截,调试过程中遇到了拿不到token的问题 我用的axios实例 let token = sto ...
- ES常用操作备忘
格式:<REST Verb>/<Index>/<Type>/<ID> 集群健康:curl -u lases:1fw@2soc#3vpn -XGET 'l ...
- JSP HTML 各种 乱码 解决方法|jsp include html乱码|include 乱码|MyEclipse 中文乱码
笔者花了一整天研究这个问题 .最终解决了所有的中文乱码问题. 不用 写 过滤器,不用改 tomcat 的配置文件 笔者使用的 软件是 MyEclipse2013 professional 版 JSP ...
- OptimalSolution(2)--二叉树问题(4)子树与拓扑结构
一.判断t1树是否包含t2树全部的拓扑结构 1 / \ 2 3 2 / \ / \ / \ 4 5 6 7 4 5 / \ / / 8 9 10 8 返回:true 解法(O(M×N)):如果t1中某 ...
- 如何理解swift中的delegate
Delegation翻译为代理或者委托,是一种设计模式.顾名思义,使class或struct能够将某些职责移交给其他类型的实例. 该设计模式通过定义一个封装(包含)delegate的protocol( ...
- Spring AOP 知识整理
通过一个多月的 Spring AOP 的学习,掌握了 Spring AOP 的基本概念.AOP 是面向切面的编程(Aspect-Oriented Programming),是基于 OOP(面向对象的编 ...
- java架构之路-(MQ专题)RocketMQ从入坑到集群详解
这次我们来说说我们的RocketMQ的安装和参数配置,先来看一下我们RocketMQ的提出和应用场景吧. 早在2009年,阿里巴巴的淘宝第一次提出了双11购物狂欢节,但是在2009年,服务器无法承受到 ...
- shell 队列实现线程并发控制
需求:并发检测1000台web服务器状态(或者并发为1000台web服务器分发文件等)如何用shell实现? 方案一:(这应该是大多数人都第一时间想到的方法吧) 思路:一个for循环1000次,顺序执 ...
- Pandas分类(category)数据处理
分类(Category)数据:直白来说,就是取值为有限的,或者说是固定数量的可能值.例如:性别.血型 指定数据类型构建分类数据 dtype="category" 以血型为例,创建一 ...
- [考试反思]阶段性总结:NOIP模拟测试7~13
苟且Rank#1.第二次分机房结束. 得到了喘息一会的权利. 在最后两场考试中大脸skyh慷慨舍弃264分让出Rank#1的故事也十分感人 然而还是有很多东西值得思考. 虽说是反思,但是还是有一些地方 ...