Martin Storsjo
5f14b6357b
ntdll: Properly restore x29/x30 for arm64 packed unwind data with local stack.
...
For the CR == 3 case, x29/x30 should be restored from x29, not from
sp, which may have been decremented further for local stack storage.
This fixes uwinding the stack for C++ exceptions in code generated
by MSVC.
Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-18 15:12:49 +02:00
Martin Storsjo
93ecc54ae5
ntdll: Pass a nonnull handler_data when continuing after a collided unwind on arm64.
...
This fixes crashes when handling GNU/mingw style SEH based C++
exceptions on arm64; in these cases unwind_full_data ended up
where it tries to write handler_rva + 1 to *handler_data.
Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-18 15:12:45 +02:00
Martin Storsjo
93082b3d52
ntdll: Fix arm64 unwind across ELF/PE boundaries.
...
The previous implementation might have given the impression of
working, as long in some cases where the PE code actually used frame
pointers, but turned out to be subly wrong.
This essentially reverts the functional aspects of 1c9fdaab0f
.
Use the new value of the Lr register, after fetching the registers
from unw_step, as the return value.
To make single-stepping unwinding work properly, treat the registers
consistently:
- Make RtlCaptureContext store the current values of x29/Fp and x30/Lr
from within the function, not the ones backed up from the stack.
- After unwinding one step, first fetch the new values of all registers,
including the new value of Lr - then use this value of Lr to set the
new value of Pc (the address to actually return to).
This makes the unwinding actually coherent in reading unwind opcodes and
return addresses from one single function; previously these were out of
sync where the return address ended up being read from the function
one step further up in the call stack.
This fixes unwinding for setjmp for binaries compiled with clang
(in mingw mode).
Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-18 15:12:41 +02:00
Alexandre Julliard
39e4b788d6
ntdll: Use the standard Interlocked* functions.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-02 15:10:04 +02:00
Alexandre Julliard
bd9a1e23f2
ntdll: Move TEB allocation to the common code.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 14:03:26 +02:00
Alexandre Julliard
9650f1d3a1
ntdll: Move signal stack size computation to the common code.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 13:34:06 +02:00
Alexandre Julliard
ffb7c595c6
ntdll: Add a helper for platform-specific threading initialization.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 13:17:07 +02:00
Zebediah Figura
feeb1c7c24
include: Rename LDR_MODULE to LDR_DATA_TABLE_ENTRY.
...
This name is used in Microsoft's public winternl.h.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-24 10:13:39 +02:00
Martin Storsjo
ea9f47a767
ntdll: Properly return errors when failing to unwind.
...
If libunwind is unavailable, make libunwind_virtual_unwind return an
error. Likewise if there was no PE exception info and we didn't try
unwinding using libunwind, we need to return an error when realizing
we were unable to unwind, instead of just warning and returning
success.
This fixes hangs/infinite loops on crashes when unwinding fails.
Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-22 17:23:39 +02:00
Alexandre Julliard
0187310966
ntdll: Implement NtSetLdtEntries().
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-01 12:38:50 +02:00
Alexandre Julliard
6169cacd0d
ntdll: Move support for getting LDT entries to the platform-specific files.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-01 12:33:29 +02:00
Alexandre Julliard
d96331d830
ntdll: Make loop counter signed.
...
Spotted by Gianfranco Costamagna.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48398
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-01-04 11:22:08 +01:00
Alexandre Julliard
6a0e0001ef
ntdll: Initialize FPU context on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-04 09:58:45 +01:00
Alexandre Julliard
85f1fbdb7e
server: Clarify naming of ARM64 floating-point registers.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-04 09:58:45 +01:00
Alexandre Julliard
5c101ed58f
ntdll: Fix unwinding of leaf functions on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-23 21:09:38 +02:00
Henri Verbeet
d82f06c075
ntdll: Properly handle 0 returns from unw_step().
...
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-22 23:04:27 +02:00
Alexandre Julliard
82c753a273
ntdll: Send first chance debug event while on signal stack on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-19 22:07:53 +02:00
Alexandre Julliard
afe8467110
ntdll: Avoid server call when possible in NtSetContextThread() on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-19 22:07:53 +02:00
Alexandre Julliard
2201229086
ntdll: Remove no longer needed function argument from setup_raise_exception() on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-12 22:47:45 +02:00
Alexandre Julliard
60eb37c6be
ntdll: Handle page fault in signal handler on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-12 22:47:44 +02:00
Alexandre Julliard
a7459d0c99
ntdll: Handle trap exception in signal handler on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-12 22:47:44 +02:00
Alexandre Julliard
769c333c6c
ntdll: Factor out setup_raise_exception() on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-12 22:47:44 +02:00
Alexandre Julliard
7736f3837e
ntdll: Use a stack_layout structure to build exception data on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-12 22:47:44 +02:00
Alexandre Julliard
5e8234b3c4
ntdll: Implement stack unwinding on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-29 20:08:14 +02:00
Alexandre Julliard
a9755d286e
ntdll: Implement RtlVirtualUnwind() for ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-29 12:01:52 +02:00
Alexandre Julliard
87d9fef2ae
ntdll: Take stack guarantee into account when handling stack overflows.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-26 12:04:25 +02:00
Alexandre Julliard
59f1c98e2c
ntdll: Run signal handlers on the signal stack on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-22 14:45:03 +02:00
Alexandre Julliard
14e34bedbf
ntdll: Share dynamic exception table functions across platforms.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-19 13:21:47 +02:00
Alexandre Julliard
fc97373f62
ntdll: Fix support for breakpoint exceptions on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 15:41:55 +02:00
Alexandre Julliard
3027c266fc
ntdll: Don't run exception handlers on the signal stack on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 15:41:25 +02:00
Alexandre Julliard
94a98cf5a2
ntdll: Implement setting the thread context on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 14:53:07 +02:00
Alexandre Julliard
1c9fdaab0f
ntdll: Save the context from the caller stack frame in RtlCaptureContext() on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 14:52:23 +02:00
Alexandre Julliard
84783ed74f
ntdll: Preserve the stack red zone on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 14:51:47 +02:00
Alexandre Julliard
85c01202ac
ntdll: Use the exception fault code to detect write access on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 14:47:17 +02:00
Alexandre Julliard
07f37f2137
ntdll: Add support for saving/restoring FPU state on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-13 14:44:41 +02:00
Alexandre Julliard
e91e6cc9bd
ntdll: Reimplement thread initialization in assembler on ARM64.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-07 00:12:25 +02:00
Rémi Bernon
00451d5edf
ntdll: Clarify NtAllocateVirtualMemory zero_bits parameter semantics.
...
This parameter was misinterpreted as an alignment parameter for the
lower bits of the allocated memory region, although it is a constraint
on the higher bits.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-13 20:55:35 +02:00
André Hentschel
0e26aaa3ed
ntdll: Add stub for RtlInstallFunctionTableCallback on ARM/ARM64.
...
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-04-01 23:25:49 +02:00
Alexandre Julliard
9f0d669239
ntdll: Rename attach_dlls() to LdrInitializeThunk().
...
Based on a patch by Andrew Wesie.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-02-14 17:57:09 +01:00
Nikolay Sivov
067f6d7463
ntdll: Implement growable unwind tables API.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46479
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-01-23 17:17:18 +01:00
André Hentschel
1b5b311cce
ntdll: Use correct PC for instruction decoding on ARM64.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46194
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-24 20:12:25 +01:00
Alex Henrie
c9109309c8
ntdll: Add RtlGrowFunctionTable stub.
...
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-03 22:27:05 +01:00
Austin English
80991720de
ntdll: Add RtlAddGrowableFunctionTable stub.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42255
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-12-03 22:27:05 +01:00
André Hentschel
b78a5db2dc
ntdll: Add more traces to raise_exception on ARM64.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46126
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-11-16 14:58:41 +01:00
André Hentschel
ebc80ad1c4
ntdll: Add stubs for RtlAddFunctionTable and RtlDeleteFunctionTable on ARM64.
...
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46143
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-11-15 09:57:28 +01:00
Alexandre Julliard
da60ea1c33
ntdll: Add a wrapper to call the unhandled exception filter.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-10-09 14:42:30 +02:00
Michael Stefaniuc
10f23ddb58
ntdll: Use the ARRAY_SIZE() macro.
...
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-08-14 10:15:59 +02:00
Alexandre Julliard
36371075f8
ntdll: Pass the server context to get/set_thread_context().
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-06-12 14:01:35 +02:00
Martin Storsjo
e0780c258f
ntdll: Update the ARM64 CONTEXT struct to match Win SDK 10.0.16299.0.
...
Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-03-19 13:13:59 +01:00
Alexandre Julliard
39c8875ff8
ntdll: Add support for running IL-only .NET executables.
...
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-02-21 09:55:05 +01:00