mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:25:08 +00:00
Kernel: Stop hardcoding syscall in signal trampoline.
We now no longer hardcode the sigreturn syscall in the signal trampoline. Because of the way inline asm inputs work, I've had to enclose the trampoline in the function signal_trampoline_dummy.
This commit is contained in:
parent
224fbb7910
commit
6e51ebad8c
1 changed files with 23 additions and 20 deletions
|
@ -793,26 +793,29 @@ void Process::sys$exit(int status)
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The trampoline preserves the current eax, pushes the signal code and
|
void signal_trampoline_dummy(void)
|
||||||
// then calls the signal handler. We do this because, when interrupting a
|
{
|
||||||
// blocking syscall, that syscall may return some special error code in eax;
|
// The trampoline preserves the current eax, pushes the signal code and
|
||||||
// This error code would likely be overwritten by the signal handler, so it's
|
// then calls the signal handler. We do this because, when interrupting a
|
||||||
// neccessary to preserve it here.
|
// blocking syscall, that syscall may return some special error code in eax;
|
||||||
asm(
|
// This error code would likely be overwritten by the signal handler, so it's
|
||||||
".intel_syntax noprefix\n"
|
// neccessary to preserve it here.
|
||||||
"asm_signal_trampoline:\n"
|
asm(
|
||||||
"push ebp\n"
|
".intel_syntax noprefix\n"
|
||||||
"mov ebp, esp\n"
|
"asm_signal_trampoline:\n"
|
||||||
"push eax\n" // we have to store eax 'cause it might be the return value from a syscall
|
"push ebp\n"
|
||||||
"sub esp, 4\n" // align the stack to 16 bytes
|
"mov ebp, esp\n"
|
||||||
"mov eax, [ebp+12]\n" // push the signal code
|
"push eax\n" // we have to store eax 'cause it might be the return value from a syscall
|
||||||
"push eax\n"
|
"sub esp, 4\n" // align the stack to 16 bytes
|
||||||
"call [ebp+8]\n" // call the signal handler
|
"mov eax, [ebp+12]\n" // push the signal code
|
||||||
"add esp, 8\n"
|
"push eax\n"
|
||||||
"mov eax, 0x2d\n" // FIXME: We shouldn't be hardcoding this.
|
"call [ebp+8]\n" // call the signal handler
|
||||||
"int 0x82\n" // sigreturn syscall
|
"add esp, 8\n"
|
||||||
"asm_signal_trampoline_end:\n"
|
"mov eax, %P0\n"
|
||||||
".att_syntax");
|
"int 0x82\n" // sigreturn syscall
|
||||||
|
"asm_signal_trampoline_end:\n"
|
||||||
|
".att_syntax" ::"i"(Syscall::SC_sigreturn));
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void asm_signal_trampoline(void);
|
extern "C" void asm_signal_trampoline(void);
|
||||||
extern "C" void asm_signal_trampoline_end(void);
|
extern "C" void asm_signal_trampoline_end(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue