Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e79fa186
Commit
e79fa186
authored
May 28, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebuild: Add support for multiple syscall descriptor tables.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
738dc41e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
49 deletions
+63
-49
import.c
tools/winebuild/import.c
+63
-49
No files found.
tools/winebuild/import.c
View file @
e79fa186
...
...
@@ -1421,7 +1421,7 @@ static int cmp_link_name( const void *e1, const void *e2 )
/* output dispatcher for system calls */
static
void
output_syscall_dispatcher
(
int
count
,
const
char
*
variant
)
static
void
output_syscall_dispatcher
(
const
char
*
variant
)
{
const
unsigned
int
invalid_param
=
0xc000000d
;
/* STATUS_INVALID_PARAMETER */
const
char
*
symbol
=
strmake
(
"__wine_syscall_dispatcher%s"
,
variant
);
...
...
@@ -1490,16 +1490,23 @@ static void output_syscall_dispatcher( int count, const char *variant )
}
output
(
"
\t
leal -0x30(%%ebp),%%ecx
\n
"
);
output
(
"
\t
movl %%ecx,%%fs:0x1f8
\n
"
);
/* x86_thread_data()->syscall_frame */
output
(
"
\t
cmpl $%u,%%eax
\n
"
,
count
);
output
(
"
\t
jae 4f
\n
"
);
output
(
"
\t
movl %%eax,%%ecx
\n
"
);
output
(
"
\t
shrl $8,%%ecx
\n
"
);
output
(
"
\t
andl $0x30,%%ecx
\n
"
);
/* syscall table number */
output
(
"
\t
movl %%eax,%%edx
\n
"
);
output
(
"
\t
andl $0xfff,%%edx
\n
"
);
/* syscall number */
if
(
UsePIC
)
{
output
(
"
\t
movl %%eax,%%edx
\n
"
);
output
(
"
\t
call %s
\n
"
,
asm_name
(
"__wine_spec_get_pc_thunk_eax"
)
);
output
(
"1:
\t
movzbl .Lsyscall_args-1b(%%eax,%%edx,1),%%ecx
\n
"
);
output
(
"1:
\t
leal %s-1b(%%eax,%%ecx),%%ebx
\n
"
,
asm_name
(
"KeServiceDescriptorTable"
)
);
needs_get_pc_thunk
=
1
;
}
else
output
(
"
\t
movzbl .Lsyscall_args(%%eax),%%ecx
\n
"
);
else
output
(
"
\t
leal %s(%%ecx),%%ebx
\n
"
,
asm_name
(
"KeServiceDescriptorTable"
)
);
output
(
"
\t
cmpl 8(%%ebx),%%edx
\n
"
);
/* table->ServiceLimit */
output
(
"
\t
jae 4f
\n
"
);
output
(
"
\t
movl 12(%%ebx),%%eax
\n
"
);
/* table->ArgumentTable */
output
(
"
\t
movzbl (%%eax,%%edx,1),%%ecx
\n
"
);
output
(
"
\t
subl %%ecx,%%esp
\n
"
);
output
(
"
\t
shrl $2,%%ecx
\n
"
);
output
(
"
\t
leal 12(%%ebp),%%esi
\n
"
);
...
...
@@ -1507,10 +1514,8 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
movl %%esp,%%edi
\n
"
);
output
(
"
\t
cld
\n
"
);
output
(
"
\t
rep; movsl
\n
"
);
if
(
UsePIC
)
output
(
"
\t
call *.Lsyscall_table-1b(%%eax,%%edx,4)
\n
"
);
else
output
(
"
\t
call *.Lsyscall_table(,%%eax,4)
\n
"
);
output
(
"
\t
movl (%%ebx),%%eax
\n
"
);
/* table->ServiceTable */
output
(
"
\t
call *(%%eax,%%edx,4)
\n
"
);
output
(
"2:
\t
movl $0,%%fs:0x1f8
\n
"
);
output
(
"
\t
leal -0x2f0(%%ebp),%%ebx
\n
"
)
;
output
(
"
\t
andl $~63,%%ebx
\n
"
);
...
...
@@ -1645,9 +1650,15 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
movq %%gs:0x30,%%rcx
\n
"
);
output
(
"
\t
leaq -0x98(%%rbp),%%rbx
\n
"
);
output
(
"
\t
movq %%rbx,0x328(%%rcx)
\n
"
);
/* amd64_thread_data()->syscall_frame */
output
(
"
\t
cmpq $%u,%%r11
\n
"
,
count
);
output
(
"
\t
movq %%r11,%%rbx
\n
"
);
output
(
"
\t
shrl $8,%%ebx
\n
"
);
output
(
"
\t
andl $0x30,%%ebx
\n
"
);
/* syscall table number */
output
(
"
\t
leaq %s(%%rip),%%rcx
\n
"
,
asm_name
(
"KeServiceDescriptorTable"
)
);
output
(
"
\t
leaq (%%rcx,%%rbx,2),%%rbx
\n
"
);
output
(
"
\t
andq $0xfff,%%r11
\n
"
);
/* syscall number */
output
(
"
\t
cmpq 16(%%rbx),%%r11
\n
"
);
/* table->ServiceLimit */
output
(
"
\t
jae 3f
\n
"
);
output
(
"
\t
leaq .Lsyscall_args(%%rip),%%rcx
\n
"
);
output
(
"
\t
movq 24(%%rbx),%%rcx
\n
"
);
/* table->ArgumentTable */
output
(
"
\t
movzbl (%%rcx,%%r11),%%ecx
\n
"
);
output
(
"
\t
subq $0x20,%%rcx
\n
"
);
output
(
"
\t
jbe 1f
\n
"
);
...
...
@@ -1660,7 +1671,7 @@ static void output_syscall_dispatcher( int count, const char *variant )
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
movq (%%rbx),%%r10
\n
"
);
/* table->ServiceTable */
output
(
"
\t
callq *(%%r10,%%r11,8)
\n
"
);
output
(
"2:
\t
movq %%gs:0x30,%%rcx
\n
"
);
output
(
"
\t
movq $0,0x328(%%rcx)
\n
"
);
...
...
@@ -1699,9 +1710,6 @@ static void output_syscall_dispatcher( int count, const char *variant )
case
CPU_ARM
:
output
(
"
\t
push {r4-r11}
\n
"
);
output
(
"
\t
add r6, sp, #40
\n
"
);
/* stack parameters */
output
(
"
\t
ldr r5, 6f+8
\n
"
);
output
(
"
\t
cmp ip, r5
\n
"
);
output
(
"
\t
bcs 5f
\n
"
);
output
(
"
\t
sub sp, sp, #8
\n
"
);
output
(
"
\t
mrc p15, 0, r7, c13, c0, 2
\n
"
);
/* NtCurrentTeb() */
output
(
"
\t
add r7, #0x1d8
\n
"
);
/* arm_thread_data()->syscall_frame */
...
...
@@ -1709,9 +1717,16 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
bfi r0, lr, #5, #1
\n
"
);
/* set thumb bit */
output
(
"
\t
str r0, [sp, #4]
\n
"
);
output
(
"
\t
str sp, [r7]
\n
"
);
/* syscall frame */
output
(
"
\t
ldr r5, 6f
+4
\n
"
);
output
(
"
\t
ldr r5, 6f
\n
"
);
if
(
UsePIC
)
output
(
"1:
\t
add r5, pc
\n
"
);
output
(
"
\t
ldrb r5, [r5, ip]
\n
"
);
/* syscall args */
output
(
"
\t
ubfx r4, ip, #12, #2
\n
"
);
/* syscall table number */
output
(
"
\t
bfc ip, #12, #20
\n
"
);
/* syscall number */
output
(
"
\t
add r4, r5, r4, lsl #4
\n
"
);
output
(
"
\t
ldr r5, [r4, #8]
\n
"
);
/* table->ServiceLimit */
output
(
"
\t
cmp ip, r5
\n
"
);
output
(
"
\t
bcs 5f
\n
"
);
output
(
"
\t
ldr r5, [r4, #12]
\n
"
);
/* table->ArgumentTable */
output
(
"
\t
ldrb r5, [r5, ip]
\n
"
);
output
(
"
\t
cmp r5, #16
\n
"
);
output
(
"
\t
it le
\n
"
);
output
(
"
\t
movle r5, #16
\n
"
);
...
...
@@ -1722,34 +1737,24 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
ldr r0, [r6, r5]
\n
"
);
output
(
"
\t
str r0, [sp, r5]
\n
"
);
output
(
"
\t
bgt 2b
\n
"
);
output
(
"
\t
ldr r5, 6f
\n
"
);
if
(
UsePIC
)
output
(
"4:
\t
add r5, pc
\n
"
);
output
(
"
\t
ldr ip, [r5, ip, lsl #2]
\n
"
);
/* syscall table */
output
(
"
\t
pop {r0-r3}
\n
"
);
/* first 4 args are in registers */
output
(
"
\t
ldr r5, [r4]
\n
"
);
/* table->ServiceTable */
output
(
"
\t
ldr ip, [r5, ip, lsl #2]
\n
"
);
output
(
"
\t
blx ip
\n
"
);
output
(
"
\t
mov ip, #0
\n
"
);
output
(
"
4:
\t
mov ip, #0
\n
"
);
output
(
"
\t
str ip, [r7]
\n
"
);
output
(
"
\t
sub ip, r6, #40
\n
"
);
output
(
"
\t
mov sp, ip
\n
"
);
output
(
"
\t
pop {r4-r12,pc}
\n
"
);
output
(
"5:
\t
movw r0, #0x%x
\n
"
,
invalid_param
&
0xffff
);
output
(
"
\t
movt r0, #0x%x
\n
"
,
invalid_param
>>
16
);
output
(
"
\t
pop {r4-r12,pc}
\n
"
);
output
(
"
\t
b 4b
\n
"
);
if
(
UsePIC
)
{
output
(
"6:
\t
.long .Lsyscall_table-4b-%u
\n
"
,
thumb_mode
?
4
:
8
);
output
(
"
\t
.long .Lsyscall_args-1b-%u
\n
"
,
thumb_mode
?
4
:
8
);
}
output
(
"6:
\t
.long %s-1b-%u
\n
"
,
asm_name
(
"KeServiceDescriptorTable"
),
thumb_mode
?
4
:
8
);
else
{
output
(
"6:
\t
.long .Lsyscall_table
\n
"
);
output
(
"
\t
.long .Lsyscall_args
\n
"
);
}
output
(
"
\t
.long %u
\n
"
,
count
);
output
(
"6:
\t
.long %s
\n
"
,
asm_name
(
"KeServiceDescriptorTable"
)
);
break
;
case
CPU_ARM64
:
output
(
"
\t
cmp x8, %u
\n
"
,
count
);
output
(
"
\t
bcs 3f
\n
"
);
output
(
"
\t
stp x29, x30, [sp,#-160]!
\n
"
);
output_cfi
(
"
\t
.cfi_def_cfa_offset 160
\n
"
);
output_cfi
(
"
\t
.cfi_offset 29, -160
\n
"
);
...
...
@@ -1771,11 +1776,18 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
stp x19, x20, [sp, #80]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 19, -80
\n
"
);
output_cfi
(
"
\t
.cfi_offset 20, -72
\n
"
);
output
(
"
\t
and x20, x8, #0xfff
\n
"
);
/* syscall number */
output
(
"
\t
ubfx x21, x8, #12, #2
\n
"
);
/* syscall table number */
output
(
"
\t
adrp x16, %s
\n
"
,
arm64_page
(
asm_name
(
"KeServiceDescriptorTable"
))
);
output
(
"
\t
add x16, x16, #%s
\n
"
,
arm64_pageoff
(
asm_name
(
"KeServiceDescriptorTable"
))
);
output
(
"
\t
add x21, x16, x21, lsl #5
\n
"
);
output
(
"
\t
ldr x16, [x21, #16]
\n
"
);
/* table->ServiceLimit */
output
(
"
\t
cmp x20, x16
\n
"
);
output
(
"
\t
bcs 4f
\n
"
);
output
(
"
\t
stp x6, x7, [sp, #64]
\n
"
);
output
(
"
\t
stp x4, x5, [sp, #48]
\n
"
);
output
(
"
\t
stp x2, x3, [sp, #32]
\n
"
);
output
(
"
\t
stp x0, x1, [sp, #16]
\n
"
);
output
(
"
\t
mov x20, x8
\n
"
);
output
(
"
\t
bl %s
\n
"
,
asm_name
(
"NtCurrentTeb"
)
);
output
(
"
\t
add x19, x0, #0x2f8
\n
"
);
/* arm64_thread_data()->syscall_frame */
output
(
"
\t
str x29, [x19]
\n
"
);
...
...
@@ -1783,8 +1795,7 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
ldp x2, x3, [sp, #32]
\n
"
);
output
(
"
\t
ldp x4, x5, [sp, #48]
\n
"
);
output
(
"
\t
ldp x6, x7, [sp, #64]
\n
"
);
output
(
"
\t
adrp x16, %s
\n
"
,
arm64_page
(
".Lsyscall_args"
)
);
output
(
"
\t
add x16, x16, #%s
\n
"
,
arm64_pageoff
(
".Lsyscall_args"
)
);
output
(
"
\t
ldr x16, [x21, #24]
\n
"
);
/* table->ArgumentTable */
output
(
"
\t
ldrb w9, [x16, x20]
\n
"
);
output
(
"
\t
subs x9, x9, #64
\n
"
);
output
(
"
\t
bls 2f
\n
"
);
...
...
@@ -1796,22 +1807,21 @@ static void output_syscall_dispatcher( int count, const char *variant )
output
(
"
\t
ldr x10, [x11, x9]
\n
"
);
output
(
"
\t
str x10, [sp, x9]
\n
"
);
output
(
"
\t
cbnz x9, 1b
\n
"
);
output
(
"2:
\t
adrp x16, %s
\n
"
,
arm64_page
(
".Lsyscall_table"
)
);
output
(
"
\t
add x16, x16, #%s
\n
"
,
arm64_pageoff
(
".Lsyscall_table"
)
);
output
(
"2:
\t
ldr x16, [x21]
\n
"
);
/* table->ServiceTable */
output
(
"
\t
ldr x16, [x16, x20, lsl 3]
\n
"
);
output
(
"
\t
blr x16
\n
"
);
output
(
"
\t
mov sp, x29
\n
"
);
output
(
"
\t
str xzr, [x19]
\n
"
);
output
(
"
\t
ldp x19, x20, [sp, #80]
\n
"
);
output
(
"
3:
\t
ldp x19, x20, [sp, #80]
\n
"
);
output
(
"
\t
ldp x21, x22, [sp, #96]
\n
"
);
output
(
"
\t
ldp x23, x24, [sp, #112]
\n
"
);
output
(
"
\t
ldp x25, x26, [sp, #128]
\n
"
);
output
(
"
\t
ldp x27, x28, [sp, #144]
\n
"
);
output
(
"
\t
ldp x29, x30, [sp], #160
\n
"
);
output
(
"
\t
ret
\n
"
);
output
(
"
3
:
\t
mov x0, #0x%x
\n
"
,
invalid_param
&
0xffff0000
);
output
(
"
4
:
\t
mov x0, #0x%x
\n
"
,
invalid_param
&
0xffff0000
);
output
(
"
\t
movk x0, #0x%x
\n
"
,
invalid_param
&
0x0000ffff
);
output
(
"
\t
ret
\n
"
);
output
(
"
\t
b 3b
\n
"
);
break
;
default:
assert
(
0
);
...
...
@@ -1842,25 +1852,29 @@ void output_syscalls( DLLSPEC *spec )
if
(
unix_lib
)
{
output_syscall_dispatcher
(
count
,
""
);
output_syscall_dispatcher
(
""
);
switch
(
target_cpu
)
{
case
CPU_x86
:
output_syscall_dispatcher
(
count
,
"_fxsave"
);
output_syscall_dispatcher
(
count
,
"_xsave"
);
output_syscall_dispatcher
(
count
,
"_xsavec"
);
output_syscall_dispatcher
(
"_fxsave"
);
output_syscall_dispatcher
(
"_xsave"
);
output_syscall_dispatcher
(
"_xsavec"
);
break
;
case
CPU_x86_64
:
output_syscall_dispatcher
(
count
,
"_xsave"
);
output_syscall_dispatcher
(
count
,
"_xsavec"
);
output_syscall_dispatcher
(
"_xsave"
);
output_syscall_dispatcher
(
"_xsavec"
);
break
;
default:
break
;
}
output
(
"
\t
.data
\n
"
);
output
(
"
\t
.align %d
\n
"
,
get_alignment
(
get_ptr_size
()
)
);
output
(
"%s
\n
"
,
asm_globl
(
"KeServiceDescriptorTable"
)
);
output
(
"
\t
%s .Lsyscall_table, 0, %u, .Lsyscall_args
\n
"
,
get_asm_ptr_keyword
(),
count
);
output
(
"
\t
%s 0, 0, 0, 0
\n
"
,
get_asm_ptr_keyword
()
);
output
(
"
\t
%s 0, 0, 0, 0
\n
"
,
get_asm_ptr_keyword
()
);
output
(
"
\t
%s 0, 0, 0, 0
\n
"
,
get_asm_ptr_keyword
()
);
output
(
".Lsyscall_table:
\n
"
);
for
(
i
=
0
;
i
<
count
;
i
++
)
output
(
"
\t
%s %s
\n
"
,
get_asm_ptr_keyword
(),
asm_name
(
get_link_name
(
syscalls
[
i
]
)));
...
...
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