Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
void * -[HelloService getValue](void * self, void * _cmd) {
var_18 = [@"Hello" retain];
var_28 = [var_18 retain];
objc_storeStrong(var_18, 0x0);
rax = [var_28 autorelease];
return rax;
0000000100000e40 55 push rbp ; Objective C Implementation defined at 0x1000010f8 (instance method), DATA XREF=0x1000010f8
0000000100000e41 4889E5 mov rbp, rsp
0000000100000e44 4883EC30 sub rsp, 0x30
0000000100000e48 48897DF8 mov qword [rbp+var_8], rdi
0000000100000e4c 488975F0 mov qword [rbp+var_10], rsi
0000000100000e50 488D3D09020000 lea rdi, qword [cfstring_Hello_thanhvu_dev] ; @"Hello", argument "instance" for method _objc_retain
0000000100000e57 488B35BA010000 mov rsi, qword [_objc_retain_100001018]
0000000100000e5e 488975E0 mov qword [rbp+var_20], rsi
0000000100000e62 FFD6 call rsi ; _objc_retain ; Retain biến s
0000000100000e64 488945E8 mov qword [rbp+var_18], rax
0000000100000e68 488B7DE8 mov rdi, qword [rbp+var_18]
0000000100000e6c 488B45E0 mov rax, qword [rbp+var_20]
0000000100000e70 FFD0 call rax
0000000100000e72 31C9 xor ecx, ecx
0000000100000e74 89CE mov esi, ecx
0000000100000e76 488D7DE8 lea rdi, qword [rbp+var_18]
0000000100000e7a 488945D8 mov qword [rbp+var_28], rax
0000000100000e7e E8A7000000 call imp___stubs__objc_storeStrong ; Release biến s
0000000100000e83 488B45D8 mov rax, qword [rbp+var_28] ; Lấy địa chỉ vùng nhớ của object mà pointer s trỏ tới
0000000100000e87 4889C7 mov rdi, rax ; argument "instance" for method imp___stubs__objc_autoreleaseReturnValue
0000000100000e8a 4883C430 add rsp, 0x30
0000000100000e8e 5D pop rbp
0000000100000e8f E98A000000 jmp imp___stubs__objc_autoreleaseReturnValue ; Thực hiện đẩy object của pointer s vào trong autorelease
void -[HelloService run](void * self, void * _cmd) {
var_18 = [[self getValue] retain];
var_20 = [var_18 retain];
NSLog(@"%@", var_18);
objc_storeStrong(var_20, 0x0);
objc_storeStrong(var_18, 0x0);
-[HelloService run]
0000000100000db0 55 push rbp ; Objective C Implementation defined at 0x1000010e0 (instance method), DATA XREF=0x1000010e0
0000000100000db1 4889E5 mov rbp, rsp
0000000100000db4 4883EC30 sub rsp, 0x30
0000000100000db8 48897DF8 mov qword [rbp+var_8], rdi ; Biến self
0000000100000dbc 488975F0 mov qword [rbp+var_10], rsi ; Biến _cmd
0000000100000dc0 488B75F8 mov rsi, qword [rbp+var_8]
0000000100000dc4 488B3D8D030000 mov rdi, qword [0x100001158] ; @selector(getValue)
0000000100000dcb 48897DD8 mov qword [rbp+var_28], rdi
0000000100000dcf 4889F7 mov rdi, rsi
0000000100000dd2 488B75D8 mov rsi, qword [rbp+var_28]
0000000100000dd6 FF1534020000 call qword [_objc_msgSend_100001010] ; _objc_msgSend, Ở đây là gọi hàm getValue từ self
0000000100000ddc 4889C7 mov rdi, rax
0000000100000ddf E840010000 call imp___stubs__objc_retainAutoreleasedReturnValue ; ARC thực hiện gọi code retain lại object được return từ [self getValue]
0000000100000de4 488945E8 mov qword [rbp+var_18], rax ; Kết quả của [self getValue] được lưu tại đây, biến helloString
0000000100000de8 488B45E8 mov rax, qword [rbp+var_18]
0000000100000dec 4889C7 mov rdi, rax
0000000100000def FF1523020000 call qword [_objc_retain_100001018] ; _objc_retain ; Object được retain lại lần nữa
0000000100000df5 488D3544020000 lea rsi, qword [cfstring___] ; @"%@"
0000000100000dfc 488945E0 mov qword [rbp+var_20], rax ; Đây là biến strongRefHelloString, khi gán strongRefHelloString thì ARC tự động gọi retain :D
0000000100000e00 488B45E8 mov rax, qword [rbp+var_18]
0000000100000e04 4889F7 mov rdi, rsi ; argument "format" for method imp___stubs__NSLog
0000000100000e07 4889C6 mov rsi, rax
0000000100000e0a B000 mov al, 0x0
0000000100000e0c E807010000 call imp___stubs__NSLog
0000000100000e11 31C9 xor ecx, ecx
0000000100000e13 89CE mov esi, ecx
0000000100000e15 488D7DE0 lea rdi, qword [rbp+var_20]
0000000100000e19 E80C010000 call imp___stubs__objc_storeStrong ; Thực hiện gọi objc_storeStrong(strongRefHelloString, 0x0) để release
0000000100000e1e 31C9 xor ecx, ecx
0000000100000e20 89CE mov esi, ecx
0000000100000e22 488D7DE8 lea rdi, qword [rbp+var_18]
0000000100000e26 E8FF000000 call imp___stubs__objc_storeStrong ; Thực hiện gọi objc_storeStrong(helloString, 0x0) để release
0000000100000e2b 4883C430 add rsp, 0x30
0000000100000e2f 5D pop rbp
0000000100000e30 C3 ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment