Lines 1-17
Link Here
|
1 |
.section .data |
1 |
.section .data |
2 |
.globl caller_return |
|
|
3 |
caller_return: |
2 |
caller_return: |
4 |
.long 0 |
3 |
.long 0 |
5 |
.globl report_entry |
|
|
6 |
report_entry: |
7 |
.long null_call |
8 |
.globl report_ret |
9 |
report_ret: |
10 |
.long null_call |
11 |
.global wrapper_target |
4 |
.global wrapper_target |
12 |
wrapper_target: |
5 |
wrapper_target: |
13 |
.long null_call |
6 |
.long null_call |
14 |
|
7 |
|
|
|
8 |
#undef __i686 /* gcc define gets in our way */ |
9 |
.section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits |
10 |
.globl __i686.get_pc_thunk.bx |
11 |
.hidden __i686.get_pc_thunk.bx |
12 |
.type __i686.get_pc_thunk.bx,@function |
13 |
__i686.get_pc_thunk.bx: |
14 |
movl (%esp), %ebx |
15 |
ret |
16 |
|
15 |
.section .text |
17 |
.section .text |
16 |
.globl null_call |
18 |
.globl null_call |
17 |
.type null_call, @function |
19 |
.type null_call, @function |
Lines 22-67
null_call:
Link Here
|
22 |
.type wrapper, @function |
24 |
.type wrapper, @function |
23 |
.balign 16,0x90 |
25 |
.balign 16,0x90 |
24 |
wrapper: |
26 |
wrapper: |
|
|
27 |
pushl $0 |
25 |
pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI) |
28 |
pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI) |
26 |
pushf # store flags |
29 |
pushf # store flags |
27 |
|
30 |
|
28 |
push %ebp # set up a stack frame |
31 |
push %ebp # set up a stack frame |
29 |
movl %esp, %ebp |
32 |
movl %esp, %ebp |
30 |
|
33 |
|
|
|
34 |
call __i686.get_pc_thunk.bx |
35 |
addl $_GLOBAL_OFFSET_TABLE_, %ebx |
36 |
|
31 |
leal 4(%ebp), %eax # push flags addr |
37 |
leal 4(%ebp), %eax # push flags addr |
32 |
push %eax |
38 |
push %eax |
33 |
leal 8(%ebp), %eax # push registers addr |
39 |
leal 8(%ebp), %eax # push registers addr |
34 |
push %eax |
40 |
push %eax |
35 |
|
41 |
|
36 |
leal 40(%ebp), %edx |
42 |
leal 44(%ebp), %edx |
37 |
movl (%ebp), %eax |
43 |
movl (%ebp), %eax |
38 |
subl %edx, %eax |
44 |
subl %edx, %eax |
39 |
push %eax |
45 |
push %eax |
40 |
push %edx |
46 |
push %edx |
41 |
|
47 |
|
42 |
call *report_entry # report entry |
48 |
call report_func@PLT # report entry |
43 |
|
49 |
|
44 |
test %eax, %eax |
50 |
test %eax, %eax |
45 |
jnz .Ldone |
51 |
jnz .Ldone |
46 |
|
52 |
|
|
|
53 |
movl 44(%ebp), %eax # switch return addresses |
54 |
movl %eax, caller_return@GOTOFF(%ebx) |
55 |
leal .Lwrapper_return@GOTOFF(%ebx), %eax |
56 |
movl %eax, 40(%ebp) |
57 |
|
58 |
movl wrapper_target@GOTOFF(%ebx), %eax |
59 |
mov %eax, 40(%ebp) # wrapper_target should return at .Lwrapper_return |
60 |
|
47 |
leave # restore %esp, %ebp |
61 |
leave # restore %esp, %ebp |
48 |
popf # restore flags |
62 |
popf # restore flags |
49 |
popa # restore registers |
63 |
popa # restore registers |
50 |
|
64 |
|
51 |
popl caller_return # switch return addresses |
65 |
ret |
52 |
pushl $.Lwrapper_return |
|
|
53 |
|
54 |
jmp *wrapper_target # wrapper_target should return at .Lwrapper_return |
55 |
|
66 |
|
56 |
.balign 16, 0x90 |
67 |
.balign 16, 0x90 |
57 |
.Lwrapper_return: |
68 |
.Lwrapper_return: |
58 |
pushl caller_return # restore the original return address |
69 |
pushl $0 # restore the original return address |
59 |
pusha # more for reference sake here |
70 |
pusha # more for reference sake here |
60 |
pushf |
71 |
pushf |
61 |
|
72 |
|
62 |
push %ebp # set up a stack frame |
73 |
push %ebp # set up a stack frame |
63 |
movl %esp, %ebp |
74 |
movl %esp, %ebp |
64 |
|
75 |
|
|
|
76 |
call __i686.get_pc_thunk.bx |
77 |
addl $_GLOBAL_OFFSET_TABLE_, %ebx |
78 |
movl caller_return@GOTOFF(%ebx), %eax |
79 |
movl %eax, 40(%ebp) # restore the original return address |
80 |
|
65 |
leal 4(%ebp), %eax # push flags addr |
81 |
leal 4(%ebp), %eax # push flags addr |
66 |
push %eax |
82 |
push %eax |
67 |
leal 8(%ebp), %eax # push registers addr |
83 |
leal 8(%ebp), %eax # push registers addr |
Lines 73-83
wrapper:
Link Here
|
73 |
push %eax |
89 |
push %eax |
74 |
push %edx |
90 |
push %edx |
75 |
|
91 |
|
76 |
call *report_ret # report the return information (same args) |
92 |
call report_func_ret@PLT# report the return information (same args) |
77 |
.Ldone: |
93 |
.Ldone: |
78 |
|
94 |
|
79 |
leave |
95 |
leave |
80 |
popf |
96 |
popf |
81 |
popa |
97 |
popa |
82 |
ret |
98 |
ret |
83 |
|
99 |
|
|
|
100 |
.section .note.GNU-stack,"",@progbits |
101 |
|