]> git.sesse.net Git - vlc/blob - loader/wrapper.S
Mac OS X gui: Revert r19259. We are not ready to do proper locking.
[vlc] / loader / wrapper.S
1 .section .data
2 .globl caller_return
3 caller_return:
4         .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
12 wrapper_target: 
13         .long null_call
14
15 .section .text
16 .globl null_call
17         .type null_call, @function
18         .balign 16,0x90
19 null_call:
20         ret
21 .globl wrapper
22         .type wrapper, @function
23         .balign 16,0x90
24 wrapper:
25         pusha                   # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI) 
26         pushf                   # store flags
27         
28         push %ebp               # set up a stack frame 
29         movl %esp, %ebp
30
31         leal 4(%ebp), %eax      # push flags addr
32         push %eax
33         leal 8(%ebp), %eax      # push registers addr
34         push %eax
35         
36         leal 40(%ebp), %edx     
37         movl (%ebp), %eax
38         subl %edx, %eax
39         push %eax
40         push %edx
41         
42         call *report_entry      # report entry
43         
44         test %eax, %eax
45         jnz .Ldone
46
47         leave                   # restore %esp, %ebp
48         popf                    # restore flags
49         popa                    # restore registers
50         
51         popl caller_return      # switch return addresses
52         pushl $.Lwrapper_return 
53         
54         jmp *wrapper_target     # wrapper_target should return at .Lwrapper_return
55
56         .balign 16, 0x90
57 .Lwrapper_return:       
58         pushl caller_return     # restore the original return address
59         pusha                   # more for reference sake here
60         pushf
61         
62         push %ebp               # set up a stack frame
63         movl %esp, %ebp
64
65         leal 4(%ebp), %eax      # push flags addr
66         push %eax
67         leal 8(%ebp), %eax      # push registers addr
68         push %eax
69
70         leal 40(%ebp), %edx     # push stack top address (relative to our entry)
71         movl (%ebp), %eax
72         subl %edx, %eax         # calculate difference between entry and previous frame
73         push %eax
74         push %edx
75
76         call *report_ret        # report the return information (same args)
77 .Ldone: 
78
79         leave
80         popf
81         popa
82         ret
83