summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-10-24 18:11:36 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-24 21:54:51 +0200
commit0a748de1a0552a8939e694053a7a5621e877ac45 (patch)
tree65212aa139b0ec07c85d6e353c84516379b6fc9a /Userland/DevTools
parentdb71c36657d1fbb5b226cad473b52d56804a8283 (diff)
downloadserenity-0a748de1a0552a8939e694053a7a5621e877ac45.zip
UE: Properly align stack for signal handlers
This issue was also present in the kernel, the description of which is provided in an identically titled commit. Note that this couldn't have affected any programs running in UserspaceEmulator as we don't support SSE instructions, and don't seem to raise faults under any conditions.
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp
index 3f751f6927..3ee6f20be0 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp
+++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp
@@ -602,7 +602,7 @@ void Emulator::dispatch_one_pending_signal()
auto old_esp = m_cpu.esp();
- u32 stack_alignment = (m_cpu.esp().value() - 56) % 16;
+ u32 stack_alignment = (m_cpu.esp().value() - 52) % 16;
m_cpu.set_esp(shadow_wrap_as_initialized(m_cpu.esp().value() - stack_alignment));
m_cpu.push32(shadow_wrap_as_initialized(m_cpu.eflags()));
@@ -621,10 +621,11 @@ void Emulator::dispatch_one_pending_signal()
m_cpu.push32(shadow_wrap_as_initialized((u32)signum));
m_cpu.push32(shadow_wrap_as_initialized(handler.handler));
- m_cpu.push32(shadow_wrap_as_initialized(0u));
VERIFY((m_cpu.esp().value() % 16) == 0);
+ m_cpu.push32(shadow_wrap_as_initialized(0u));
+
m_cpu.set_eip(m_signal_trampoline);
}