2010-02-05 11:00:59 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define GLUE(a, b) a ## b
|
|
|
|
#define JOIN(a, b) GLUE(a, b)
|
|
|
|
#define MANGLE(s) JOIN(EXTERN_ASM, s)
|
|
|
|
|
2010-02-05 10:54:28 +00:00
|
|
|
.data
|
2010-02-05 11:00:59 +00:00
|
|
|
.globl MANGLE(caller_return)
|
|
|
|
MANGLE(caller_return):
|
2002-11-24 21:45:23 +00:00
|
|
|
.long 0
|
2010-02-05 11:00:59 +00:00
|
|
|
.globl MANGLE(report_entry)
|
|
|
|
MANGLE(report_entry):
|
|
|
|
.long MANGLE(null_call)
|
|
|
|
.globl MANGLE(report_ret)
|
|
|
|
MANGLE(report_ret):
|
|
|
|
.long MANGLE(null_call)
|
|
|
|
.global MANGLE(wrapper_target)
|
|
|
|
MANGLE(wrapper_target):
|
|
|
|
.long MANGLE(null_call)
|
2002-11-24 21:45:23 +00:00
|
|
|
|
2010-02-05 10:54:28 +00:00
|
|
|
.text
|
2010-02-05 11:00:59 +00:00
|
|
|
.globl MANGLE(null_call)
|
|
|
|
.type MANGLE(null_call), @function
|
2002-11-25 20:37:12 +00:00
|
|
|
.balign 16,0x90
|
2010-02-05 11:00:59 +00:00
|
|
|
MANGLE(null_call):
|
2002-11-24 21:45:23 +00:00
|
|
|
ret
|
2010-02-05 11:00:59 +00:00
|
|
|
.globl MANGLE(wrapper)
|
|
|
|
.type MANGLE(wrapper), @function
|
2002-11-25 20:37:12 +00:00
|
|
|
.balign 16,0x90
|
2010-02-05 11:00:59 +00:00
|
|
|
MANGLE(wrapper):
|
2009-07-06 23:26:13 +00:00
|
|
|
pusha # store registers (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI)
|
2002-11-24 21:45:23 +00:00
|
|
|
pushf # store flags
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
push %ebp # set up a stack frame
|
2002-11-24 21:45:23 +00:00
|
|
|
movl %esp, %ebp
|
|
|
|
|
|
|
|
leal 4(%ebp), %eax # push flags addr
|
|
|
|
push %eax
|
|
|
|
leal 8(%ebp), %eax # push registers addr
|
|
|
|
push %eax
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
leal 40(%ebp), %edx
|
2002-11-24 21:45:23 +00:00
|
|
|
movl (%ebp), %eax
|
|
|
|
subl %edx, %eax
|
|
|
|
push %eax
|
|
|
|
push %edx
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-02-05 11:00:59 +00:00
|
|
|
call *MANGLE(report_entry) # report entry
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-24 21:45:23 +00:00
|
|
|
test %eax, %eax
|
|
|
|
jnz .Ldone
|
|
|
|
|
|
|
|
leave # restore %esp, %ebp
|
|
|
|
popf # restore flags
|
|
|
|
popa # restore registers
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-02-05 11:00:59 +00:00
|
|
|
popl MANGLE(caller_return) # switch return addresses
|
2009-07-06 23:26:13 +00:00
|
|
|
pushl $.Lwrapper_return
|
|
|
|
|
2010-02-05 11:00:59 +00:00
|
|
|
jmp *MANGLE(wrapper_target) # wrapper_target should return at .Lwrapper_return
|
2002-11-24 21:45:23 +00:00
|
|
|
|
2002-11-25 20:37:12 +00:00
|
|
|
.balign 16, 0x90
|
2009-07-06 23:26:13 +00:00
|
|
|
.Lwrapper_return:
|
2010-02-05 11:00:59 +00:00
|
|
|
pushl MANGLE(caller_return) # restore the original return address
|
2002-11-24 21:45:23 +00:00
|
|
|
pusha # more for reference sake here
|
|
|
|
pushf
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-24 21:45:23 +00:00
|
|
|
push %ebp # set up a stack frame
|
|
|
|
movl %esp, %ebp
|
|
|
|
|
|
|
|
leal 4(%ebp), %eax # push flags addr
|
|
|
|
push %eax
|
|
|
|
leal 8(%ebp), %eax # push registers addr
|
|
|
|
push %eax
|
|
|
|
|
|
|
|
leal 40(%ebp), %edx # push stack top address (relative to our entry)
|
|
|
|
movl (%ebp), %eax
|
|
|
|
subl %edx, %eax # calculate difference between entry and previous frame
|
|
|
|
push %eax
|
|
|
|
push %edx
|
|
|
|
|
2010-02-05 11:00:59 +00:00
|
|
|
call *MANGLE(report_ret) # report the return information (same args)
|
2009-07-06 23:26:13 +00:00
|
|
|
.Ldone:
|
2002-11-24 21:45:23 +00:00
|
|
|
|
|
|
|
leave
|
|
|
|
popf
|
|
|
|
popa
|
|
|
|
ret
|