-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfib-go.asm
74 lines (72 loc) · 1.76 KB
/
fib-go.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;; This file was _much_ larger originally, I cut a lot of stuff to make it manageable.
;; That's our outer function:
main.fib:
cmp 0x10(%r14),%rsp
jbe 48301b <main.fib+0x5b>
sub $0x38,%rsp
mov %rbp,0x30(%rsp)
lea 0x30(%rsp),%rbp
movq $0x0,0x18(%rsp)
movups %xmm15,0x20(%rsp)
lea 0x56(%rip),%rsi # 483040 <main.fib.func1>
mov %rsi,0x20(%rsp)
lea 0x18(%rsp),%rsi
mov %rsi,0x28(%rsp)
lea 0x20(%rsp),%rdx
mov %rdx,0x18(%rsp)
mov 0x20(%rsp),%rsi
xor %ebx,%ebx
mov $0x1,%ecx
;; And here it calls the inner function.
call *%rsi
;; Interestingly, it's a dynamic call for no obvious reason.
mov 0x30(%rsp),%rbp
add $0x38,%rsp
ret
mov %rax,0x8(%rsp)
call 45bd00 <runtime.morestack_noctxt.abi0>
mov 0x8(%rsp),%rax
jmp 482fc0 <main.fib>
;; That's our inner function
main.fib.func1:
cmp 0x10(%r14),%rsp
jbe 48309f <main.fib.func1+0x5f>
sub $0x20,%rsp
mov %rbp,0x18(%rsp)
lea 0x18(%rsp),%rbp
mov 0x8(%rdx),%rsi
test %rax,%rax
je 483092 <main.fib.func1+0x52>
nopl (%rax)
cmp $0x1,%rax
jne 483073 <main.fib.func1+0x33>
mov %rcx,%rax
mov 0x18(%rsp),%rbp
add $0x20,%rsp
ret
mov (%rsi),%rdx
mov (%rdx),%rsi
dec %rax
lea (%rcx,%rbx,1),%rdi
mov %rcx,%rbx
mov %rdi,%rcx
;; And this call is clearly a recursive call
;; (I double-checked it in debugger to be sure)
call *%rsi
;; That's a dynamic call again. Why, Go? Why?
mov 0x18(%rsp),%rbp
add $0x20,%rsp
ret
mov %rbx,%rax
mov 0x18(%rsp),%rbp
add $0x20,%rsp
ret
mov %rax,0x8(%rsp)
mov %rbx,0x10(%rsp)
mov %rcx,0x18(%rsp)
;; Fun allocation stuff: that's what makes binaries so large.
call 45bc60 <runtime.morestack.abi0>
mov 0x8(%rsp),%rax
mov 0x10(%rsp),%rbx
mov 0x18(%rsp),%rcx
jmp 483040 <main.fib.func1>