Configure needs AS to be set for the Makefiles.
[mplayer/glamo.git] / loader / wrapper.S
blob7656a00f92f9b402594bb81bdbc08b8f58df7c52
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
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
28         push %ebp               # set up a stack frame
29         movl %esp, %ebp
31         leal 4(%ebp), %eax      # push flags addr
32         push %eax
33         leal 8(%ebp), %eax      # push registers addr
34         push %eax
36         leal 40(%ebp), %edx
37         movl (%ebp), %eax
38         subl %edx, %eax
39         push %eax
40         push %edx
42         call *report_entry      # report entry
44         test %eax, %eax
45         jnz .Ldone
47         leave                   # restore %esp, %ebp
48         popf                    # restore flags
49         popa                    # restore registers
51         popl caller_return      # switch return addresses
52         pushl $.Lwrapper_return
54         jmp *wrapper_target     # wrapper_target should return at .Lwrapper_return
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
62         push %ebp               # set up a stack frame
63         movl %esp, %ebp
65         leal 4(%ebp), %eax      # push flags addr
66         push %eax
67         leal 8(%ebp), %eax      # push registers addr
68         push %eax
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
76         call *report_ret        # report the return information (same args)
77 .Ldone:
79         leave
80         popf
81         popa
82         ret