What you probably want to do is rewrite EXC_CallHandler in assembler, making sure you use the right instructions. This would also address the issue with %ebp where we currently depend on the way gcc compiles the code, which is not ideal.
Excellent idea!
Something like this should work:
// prologue
push ebp push ecx mov ebp, esp mov ecx, handler
// create a new frame on the stack
push ??? // stack low push ??? // stack top push fs:[00000000] // previous frame pointer
// set the new frame
mov fs:[00000000], esp
// call the handler
push dispatcherpush context push frame push record call ecx // exact instruction required by Shrinker
// eax now contains the return code. // restore the stack
mov esp, fs:[00000000] // exact instruction required by Shrinker
// pop off the previous frame to be current.
pop fs:[00000000]
// epilogue
mov esp, ebp pop ecx pop ebp ret
What I'm not certain about is what to put in as the top of the stack and the minimum stack. I also don't know what the purpose of nested_handler is in the arguments, and how it works.
--Rob