You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
Added ntdll-aarch64-TEB patchset
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
From d99a6180cdca6274f1a8b868c38a89883daf6e23 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Wed, 21 Jun 2017 11:42:40 +0300
|
||||
Subject: [PATCH] configure: Avoid clobbering x18 on arm64 within wine
|
||||
|
||||
On aarch64/arm64 on linux, the compiler is free to use x18 for normal
|
||||
code generation (while the register is reserved on iOS/darwin, and
|
||||
on windows).
|
||||
|
||||
If targeting arm64, check for the flags that allows this register to
|
||||
be left untouched (the flag is supported both by gcc and clang).
|
||||
|
||||
Similar issues can still pop up as soon as system library functions
|
||||
that happen to touch x18 are called, unless the system libraries have
|
||||
been built with the same flag.
|
||||
|
||||
Signed-off-by: Martin Storsjo <martin@martin.st>
|
||||
---
|
||||
configure.ac | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index d1502bacf7..6cf838ef09 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -212,6 +212,10 @@ case $host in
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>]], [[void func(__builtin_ms_va_list *args);]])],
|
||||
[wine_cv_builtin_ms_va_list=yes],[wine_cv_builtin_ms_va_list=no])])
|
||||
test $wine_cv_builtin_ms_va_list != no || AC_MSG_ERROR([You need clang >= 5.0 to build Wine for arm64.])
|
||||
+ # Avoid clobbering the x18 register which is reserved in windows.
|
||||
+ # This isn't complete/enough unless all of the system libraries have
|
||||
+ # been built with the same flag though.
|
||||
+ WINE_TRY_CFLAGS([-ffixed-x18], [CFLAGS="$CFLAGS -ffixed-x18"])
|
||||
;;
|
||||
i[[3456789]]86*)
|
||||
enable_win16=${enable_win16:-yes}
|
||||
--
|
||||
2.17.1
|
||||
|
@@ -0,0 +1,60 @@
|
||||
From ea639387658c32c0e7df03795462f140f8921f06 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Wed, 16 Aug 2017 23:48:40 +0300
|
||||
Subject: [PATCH] ntdll: Always restore TEB to x18 on aarch 64 on return
|
||||
from calls to builtins
|
||||
|
||||
This requires always enabling relaying of calls though.
|
||||
|
||||
This isn't enough for cases where builtin functions call back into
|
||||
the user code though, but works well enough for all pratical cases
|
||||
I've run so far.
|
||||
|
||||
This does give a bit of performance overhead, but it makes it
|
||||
possible to run most real arm64 binaries (all I've tried).
|
||||
|
||||
Signed-off-by: Martin Storsjo <martin@martin.st>
|
||||
---
|
||||
dlls/ntdll/loader.c | 8 +++++++-
|
||||
dlls/ntdll/relay.c | 4 ++++
|
||||
2 files changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
|
||||
index 994ff6f215..1f40021b7a 100644
|
||||
--- a/dlls/ntdll/loader.c
|
||||
+++ b/dlls/ntdll/loader.c
|
||||
@@ -1827,7 +1827,13 @@ static void load_builtin_callback( void *module, const char *filename )
|
||||
SERVER_END_REQ;
|
||||
|
||||
/* setup relay debugging entry points */
|
||||
- if (TRACE_ON(relay)) RELAY_SetupDLL( module );
|
||||
+#ifdef __aarch64__
|
||||
+ /* Always enable relay entry points on aarch64, to allow restoring
|
||||
+ * the TEB to x18. */
|
||||
+#else
|
||||
+ if (TRACE_ON(relay))
|
||||
+#endif
|
||||
+ RELAY_SetupDLL( module );
|
||||
}
|
||||
|
||||
|
||||
diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c
|
||||
index 7974587c4a..1d88eddb3f 100644
|
||||
--- a/dlls/ntdll/relay.c
|
||||
+++ b/dlls/ntdll/relay.c
|
||||
@@ -709,8 +709,12 @@ static LONGLONG WINAPI relay_call( struct relay_descr *descr, unsigned int idx,
|
||||
{
|
||||
unsigned int nb_args;
|
||||
void *func = relay_trace_entry( descr, idx, stack, &nb_args );
|
||||
+ void *teb;
|
||||
LONGLONG ret = call_entry_point( func, nb_args, stack );
|
||||
relay_trace_exit( descr, idx, stack[-1], ret );
|
||||
+ teb = NtCurrentTeb();
|
||||
+ /* Restore the TEB pointer, in case the builtin call clobbered it. */
|
||||
+ __asm__ __volatile__( "mov x18, %0" : : "r" (teb) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
1
patches/ntdll-aarch-TEB/definition
Normal file
1
patches/ntdll-aarch-TEB/definition
Normal file
@@ -0,0 +1 @@
|
||||
Fixes: [38780] AArch64 platforms: register X18 (TEB) must remain reserved for Wine to run 64-bit ARM Windows applications.
|
Reference in New Issue
Block a user