From a723ff09c1946fc7a9bfc88a17371cd97f393368 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 17 Feb 2024 16:19:53 -0800 Subject: [PATCH] Fixes VDSO crash in 64-bit code Ever since #3406 this has been crashing. Struct tail padding was saving this before. --- .../Tools/LinuxEmulation/VDSO_Emulation.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp index a4c2fe31d..75f05c82a 100644 --- a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp +++ b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp @@ -36,7 +36,7 @@ namespace FEX::VDSO { using HandlerPtr = void(*)(void*); namespace x64 { - static uint64_t SyscallRet(int Result) { + static uint64_t SyscallRet(uint64_t Result) { if (Result == -1) { return -errno; } @@ -50,7 +50,7 @@ namespace FEX::VDSO { uint64_t rv; } *args = reinterpret_cast(ArgsRV); - int Result = ::time(args->a_0); + uint64_t Result = ::time(args->a_0); args->rv = SyscallRet(Result); } @@ -58,7 +58,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { struct timeval *tv; struct timezone *tz; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); int Result = ::gettimeofday(args->tv, args->tz); @@ -69,7 +69,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { clockid_t clk_id; struct timespec *tp; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); int Result = ::clock_gettime(args->clk_id, args->tp); @@ -80,7 +80,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { clockid_t clk_id; struct timespec *tp; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); int Result = ::clock_getres(args->clk_id, args->tp); @@ -91,7 +91,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { uint32_t *cpu; uint32_t *node; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); int Result = FHU::Syscalls::getcpu(args->cpu, args->node); @@ -114,7 +114,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { struct timeval *tv; struct timezone *tz; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); args->rv = VDSOHandlers::GetTimeOfDayPtr(args->tv, args->tz); @@ -124,7 +124,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { clockid_t clk_id; struct timespec *tp; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); args->rv = VDSOHandlers::ClockGetTimePtr(args->clk_id, args->tp); @@ -134,7 +134,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { clockid_t clk_id; struct timespec *tp; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); args->rv = VDSOHandlers::ClockGetResPtr(args->clk_id, args->tp); @@ -144,7 +144,7 @@ namespace FEX::VDSO { struct __attribute__((packed)) ArgsRV_t { uint32_t *cpu; uint32_t *node; - uint64_t rv; + int rv; } *args = reinterpret_cast(ArgsRV); args->rv = VDSOHandlers::GetCPUPtr(args->cpu, args->node);