Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
917a206b
Commit
917a206b
authored
Jul 08, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebuild: Generate Windows-style syscall thunks on x86_64.
Based on patches by Michael Müller. Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
20715ee3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
7 deletions
+67
-7
mapping.c
server/mapping.c
+5
-1
import.c
tools/winebuild/import.c
+62
-6
No files found.
server/mapping.c
View file @
917a206b
...
...
@@ -964,7 +964,11 @@ struct object *create_user_data_mapping( struct object *root, const struct unico
if
(
!
(
mapping
=
create_mapping
(
root
,
name
,
OBJ_OPENIF
,
sizeof
(
KSHARED_USER_DATA
),
SEC_COMMIT
,
0
,
FILE_READ_DATA
|
FILE_WRITE_DATA
,
NULL
)))
return
NULL
;
ptr
=
mmap
(
NULL
,
mapping
->
size
,
PROT_WRITE
,
MAP_SHARED
,
get_unix_fd
(
mapping
->
fd
),
0
);
if
(
ptr
!=
MAP_FAILED
)
user_shared_data
=
ptr
;
if
(
ptr
!=
MAP_FAILED
)
{
user_shared_data
=
ptr
;
user_shared_data
->
SystemCallPad
[
0
]
=
1
;
}
return
&
mapping
->
obj
;
}
...
...
tools/winebuild/import.c
View file @
917a206b
...
...
@@ -1484,12 +1484,46 @@ void output_syscalls( DLLSPEC *spec )
output
(
"
\t
jmp 2b
\n
"
);
break
;
case
CPU_x86_64
:
output
(
"
\t
pushq %%rbp
\n
"
);
output_cfi
(
".cfi_adjust_cfa_offset 8"
);
output_cfi
(
".cfi_rel_offset %%rbp,0"
);
output
(
"
\t
movq %%rsp,%%rbp
\n
"
);
output_cfi
(
".cfi_def_cfa_register %%rbp"
);
output
(
"
\t
pushq %%rsi
\n
"
);
output_cfi
(
".cfi_rel_offset %%rsi,-8"
);
output
(
"
\t
pushq %%rdi
\n
"
);
output_cfi
(
".cfi_rel_offset %%rdi,-16"
);
/* Legends of Runeterra hooks the first system call return instruction, and
* depends on us returning to it. Adjust the return address accordingly. */
output
(
"
\t
subq $0xb,0x8(%%rbp)
\n
"
);
output
(
"
\t
cmpq $%u,%%rax
\n
"
,
count
);
output
(
"
\t
jae 1f
\n
"
);
output
(
"
\t
jae 3f
\n
"
);
output
(
"
\t
movzbq .Lsyscall_args(%%rip),%%rcx
\n
"
);
output
(
"
\t
subq $0x20,%%rcx
\n
"
);
output
(
"
\t
jbe 1f
\n
"
);
output
(
"
\t
subq %%rcx,%%rsp
\n
"
);
output
(
"
\t
shrq $3,%%rcx
\n
"
);
output
(
"
\t
leaq 0x38(%%rbp),%%rsi
\n
"
);
output
(
"
\t
andq $~15,%%rsp
\n\t
"
);
output
(
"
\t
movq %%rsp,%%rdi
\n
"
);
output
(
"
\t
cld
\n
"
);
output
(
"
\t
rep; movsq
\n
"
);
output
(
"1:
\t
movq %%r10,%%rcx
\n
"
);
output
(
"
\t
subq $0x20,%%rsp
\n
"
);
output
(
"
\t
leaq .Lsyscall_table(%%rip),%%r10
\n
"
);
output
(
"
\t
jmpq *(%%r10,%%rax,8)
\n
"
);
output
(
"1:
\t
movl $0x%x,%%eax
\n
"
,
invalid_param
);
output
(
"
\t
callq *(%%r10,%%rax,8)
\n
"
);
output
(
"2:
\t
leaq -0x10(%%rbp),%%rsp
\n
"
);
output
(
"
\t
popq %%rdi
\n
"
);
output_cfi
(
".cfi_same_value %%rdi"
);
output
(
"
\t
popq %%rsi
\n
"
);
output_cfi
(
".cfi_same_value %%rsi"
);
output_cfi
(
".cfi_def_cfa_register %%rsp"
);
output
(
"
\t
popq %%rbp
\n
"
);
output_cfi
(
".cfi_adjust_cfa_offset -8"
);
output_cfi
(
".cfi_same_value %%rbp"
);
output
(
"
\t
ret
\n
"
);
output
(
"3:
\t
movl $0x%x,%%eax
\n
"
,
invalid_param
);
output
(
"
\t
jmp 2b
\n
"
);
break
;
case
CPU_ARM
:
output
(
"
\t
ldr r1, 4f
\n
"
);
...
...
@@ -1562,9 +1596,31 @@ void output_syscalls( DLLSPEC *spec )
output
(
"
\t
ret $%u
\n
"
,
get_args_size
(
odp
));
break
;
case
CPU_x86_64
:
/* FIXME: syscall thunks not binary-compatible yet */
output
(
"
\t
movl $%u,%%eax
\n
"
,
i
);
output
(
"
\t
jmpq *%s(%%rip)
\n
"
,
asm_name
(
"__wine_syscall_dispatcher"
)
);
/* Chromium depends on syscall thunks having the same form as on
* Windows. For 64-bit systems the only viable form we can emulate is
* having an int $0x2e fallback. Since actually using an interrupt is
* expensive, and since for some reason Chromium doesn't actually
* validate that instruction, we can just put a jmp there instead. */
output
(
"
\t
.byte 0x4c,0x8b,0xd1
\n
"
);
/* movq %rcx,%r10 */
output
(
"
\t
.byte 0xb8
\n
"
);
/* movl $i,%eax */
output
(
"
\t
.long %u
\n
"
,
i
);
output
(
"
\t
.byte 0xf6,0x04,0x25,0x08,0x03,0xfe,0x7f,0x01
\n
"
);
/* testb $1,0x7ffe0308 */
output
(
"
\t
.byte 0x75,0x03
\n
"
);
/* jne 1f */
output
(
"
\t
.byte 0x0f,0x05
\n
"
);
/* syscall */
output
(
"
\t
.byte 0xc3
\n
"
);
/* ret */
output
(
"
\t
jmp 1f
\n
"
);
output
(
"
\t
.byte 0xc3
\n
"
);
/* ret */
if
(
target_platform
==
PLATFORM_WINDOWS
)
{
output
(
"1:
\t
.byte 0xff,0x14,0x25
\n
"
);
/* 2: callq *(__wine_syscall_dispatcher) */
output
(
"
\t
.long __wine_syscall_dispatcher
\n
"
);
}
else
{
output
(
"
\t
nop
\n
"
);
output
(
"1:
\t
callq *%s(%%rip)
\n
"
,
asm_name
(
"__wine_syscall_dispatcher"
)
);
}
output
(
"
\t
ret
\n
"
);
break
;
case
CPU_ARM
:
output
(
"
\t
push {r0-r1}
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment