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
a06d60bd
Commit
a06d60bd
authored
Feb 19, 2021
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebuild: Factor out output_syscall_dispatcher.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a0a62463
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
262 additions
and
254 deletions
+262
-254
import.c
tools/winebuild/import.c
+262
-254
No files found.
tools/winebuild/import.c
View file @
a06d60bd
...
...
@@ -1425,10 +1425,270 @@ static int cmp_link_name( const void *e1, const void *e2 )
}
/* output dispatcher for system calls */
static
void
output_syscall_dispatcher
(
int
count
)
{
const
unsigned
int
invalid_param
=
0xc000000d
;
/* STATUS_INVALID_PARAMETER */
output
(
"
\t
.align %d
\n
"
,
get_alignment
(
4
)
);
output
(
"
\t
%s
\n
"
,
func_declaration
(
"__wine_syscall_dispatcher"
)
);
output
(
"%s
\n
"
,
asm_globl
(
"__wine_syscall_dispatcher"
)
);
output_cfi
(
".cfi_startproc"
);
switch
(
target_cpu
)
{
case
CPU_x86
:
output
(
"
\t
pushl %%ebp
\n
"
);
output_cfi
(
".cfi_adjust_cfa_offset 4
\n
"
);
output_cfi
(
".cfi_rel_offset %%ebp,0
\n
"
);
output
(
"
\t
movl %%esp,%%ebp
\n
"
);
output_cfi
(
".cfi_def_cfa_register %%ebp
\n
"
);
output
(
"
\t
pushl %%ebx
\n
"
);
output_cfi
(
".cfi_rel_offset %%ebx,-4
\n
"
);
output
(
"
\t
pushl %%esi
\n
"
);
output_cfi
(
".cfi_rel_offset %%esi,-8
\n
"
);
output
(
"
\t
pushl %%edi
\n
"
);
output_cfi
(
".cfi_rel_offset %%edi,-12
\n
"
);
output
(
"
\t
movl %%esp,%%fs:0x1f8
\n
"
);
/* x86_thread_data()->syscall_frame */
output
(
"
\t
cmpl $%u,%%eax
\n
"
,
count
);
output
(
"
\t
jae 3f
\n
"
);
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
"
);
needs_get_pc_thunk
=
1
;
}
else
output
(
"
\t
movzbl .Lsyscall_args(%%eax),%%ecx
\n
"
);
output
(
"
\t
subl %%ecx,%%esp
\n
"
);
output
(
"
\t
shrl $2,%%ecx
\n
"
);
output
(
"
\t
leal 12(%%ebp),%%esi
\n
"
);
output
(
"
\t
andl $~15,%%esp
\n
"
);
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
leal -12(%%ebp),%%esp
\n
"
);
output
(
"2:
\t
movl $0,%%fs:0x1f8
\n
"
);
output
(
"
\t
popl %%edi
\n
"
);
output_cfi
(
".cfi_same_value %%edi
\n
"
);
output
(
"
\t
popl %%esi
\n
"
);
output_cfi
(
".cfi_same_value %%esi
\n
"
);
output
(
"
\t
popl %%ebx
\n
"
);
output_cfi
(
".cfi_same_value %%ebx
\n
"
);
output
(
"
\t
popl %%ebp
\n
"
);
output_cfi
(
".cfi_def_cfa %%esp,4
\n
"
);
output_cfi
(
".cfi_same_value %%ebp
\n
"
);
output
(
"
\t
ret
\n
"
);
output
(
"3:
\t
movl $0x%x,%%eax
\n
"
,
invalid_param
);
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
leaq -0x10(%%rbp),%%rsp
\n
"
);
output
(
"
\t
pushfq
\n
"
);
output
(
"
\t
subq $0x280,%%rsp
\n
"
);
output
(
"
\t
andq $~63,%%rsp
\n
"
);
output
(
"
\t
movq %%rbx,-0x90(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%rbx,-144"
);
output
(
"
\t
movq %%rsi,-0x78(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%rsi,-120"
);
output
(
"
\t
movq %%rdi,-0x70(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%rdi,-112"
);
output
(
"
\t
movq %%r12,-0x48(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%r12,-72"
);
output
(
"
\t
movq %%r13,-0x40(%%rbp)
\n
"
);
output
(
"
\t
movq %%r14,-0x38(%%rbp)
\n
"
);
output
(
"
\t
movq %%r15,-0x30(%%rbp)
\n
"
);
/* 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
movq 0x8(%%rbp),%%rbx
\n
"
);
output
(
"
\t
movq %%rbx,-0x28(%%rbp)
\n
"
);
output
(
"
\t
leaq 0x10(%%rbp),%%rbx
\n
"
);
output
(
"
\t
movq %%rbx,-0x10(%%rbp)
\n
"
);
output
(
"
\t
movw %%cs,-0x20(%%rbp)
\n
"
);
output
(
"
\t
movw %%ds,-0x1e(%%rbp)
\n
"
);
output
(
"
\t
movw %%es,-0x1c(%%rbp)
\n
"
);
output
(
"
\t
movw %%fs,-0x1a(%%rbp)
\n
"
);
output
(
"
\t
movw %%ss,-0x8(%%rbp)
\n
"
);
output
(
"
\t
movw %%gs,-0x6(%%rbp)
\n
"
);
output
(
"
\t
movq %%rsp,%%r12
\n
"
);
output
(
"
\t
fxsave64 (%%r12)
\n
"
);
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,%%rax
\n
"
,
count
);
output
(
"
\t
jae 3f
\n
"
);
output
(
"
\t
leaq .Lsyscall_args(%%rip),%%rcx
\n
"
);
output
(
"
\t
movzbl (%%rcx,%%rax),%%ecx
\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
callq *(%%r10,%%rax,8)
\n
"
);
output
(
"2:
\t
movq %%gs:0x30,%%rcx
\n
"
);
output
(
"
\t
movq $0,0x328(%%rcx)
\n
"
);
output
(
"
\t
fxrstor64 (%%r12)
\n
"
);
output
(
"
\t
movq -0x30(%%rbp),%%r15
\n
"
);
output
(
"
\t
movq -0x38(%%rbp),%%r14
\n
"
);
output
(
"
\t
movq -0x40(%%rbp),%%r13
\n
"
);
output
(
"
\t
movq -0x48(%%rbp),%%r12
\n
"
);
output_cfi
(
".cfi_same_value %%r12"
);
output
(
"
\t
movq -0x70(%%rbp),%%rdi
\n
"
);
output_cfi
(
".cfi_same_value %%rdi"
);
output
(
"
\t
movq -0x78(%%rbp),%%rsi
\n
"
);
output_cfi
(
".cfi_same_value %%rsi"
);
output
(
"
\t
movq -0x90(%%rbp),%%rbx
\n
"
);
output_cfi
(
".cfi_same_value %%rbx"
);
output
(
"
\t
leaq -0x28(%%rbp),%%rsp
\n
"
);
output_cfi
(
".cfi_def_cfa_register %%rsp"
);
output_cfi
(
".cfi_adjust_cfa_offset 40"
);
output
(
"
\t
movq (%%rbp),%%rbp
\n
"
);
output_cfi
(
".cfi_same_value %%rbp"
);
output
(
"
\t
iretq
\n
"
);
output
(
"3:
\t
movl $0x%x,%%eax
\n
"
,
invalid_param
);
output
(
"
\t
jmp 2b
\n
"
);
break
;
case
CPU_ARM
:
output
(
"
\t
push {r5-r11,lr}
\n
"
);
output
(
"
\t
add r6, sp, #40
\n
"
);
/* stack parameters */
output
(
"
\t
ldr r5, 6f+8
\n
"
);
output
(
"
\t
cmp r4, 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 */
output
(
"
\t
mrs ip, CPSR
\n
"
);
output
(
"
\t
str ip, [sp, #4]
\n
"
);
output
(
"
\t
str sp, [r7]
\n
"
);
/* syscall frame */
output
(
"
\t
ldr r5, 6f+4
\n
"
);
if
(
UsePIC
)
output
(
"1:
\t
add r5, pc
\n
"
);
output
(
"
\t
ldrb r5, [r5, r4]
\n
"
);
/* syscall args */
output
(
"
\t
subs r5, #16
\n
"
);
/* first 4 args are in registers */
output
(
"
\t
ble 3f
\n
"
);
output
(
"
\t
sub ip, sp, r5
\n
"
);
output
(
"
\t
and ip, #~7
\n
"
);
output
(
"
\t
mov sp, ip
\n
"
);
output
(
"2:
\t
subs r5, r5, #4
\n
"
);
output
(
"
\t
ldr ip, [r6, r5]
\n
"
);
output
(
"
\t
str ip, [sp, r5]
\n
"
);
output
(
"
\t
bgt 2b
\n
"
);
output
(
"3:
\t
ldr r5, 6f
\n
"
);
if
(
UsePIC
)
output
(
"4:
\t
add r5, pc
\n
"
);
output
(
"
\t
ldr ip, [r5, r4, lsl #2]
\n
"
);
/* syscall table */
output
(
"
\t
blx ip
\n
"
);
output
(
"
\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 {r5-r11,pc}
\n
"
);
output
(
"5:
\t
ldr r0, 6f+12
\n
"
);
output
(
"
\t
pop {r5-r11,pc}
\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
);
}
else
{
output
(
"6:
\t
.long .Lsyscall_table
\n
"
);
output
(
"
\t
.long .Lsyscall_args
\n
"
);
}
output
(
"
\t
.long %u
\n
"
,
count
);
output
(
"
\t
.long 0x%x
\n
"
,
invalid_param
);
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
"
);
output_cfi
(
"
\t
.cfi_offset 30, -152
\n
"
);
output
(
"
\t
mov x29, sp
\n
"
);
output_cfi
(
"
\t
.cfi_def_cfa_register 29
\n
"
);
output
(
"
\t
stp x27, x28, [sp, #144]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 27, -16
\n
"
);
output_cfi
(
"
\t
.cfi_offset 28, -8
\n
"
);
output
(
"
\t
stp x25, x26, [sp, #128]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 25, -32
\n
"
);
output_cfi
(
"
\t
.cfi_offset 26, -24
\n
"
);
output
(
"
\t
stp x23, x24, [sp, #112]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 23, -48
\n
"
);
output_cfi
(
"
\t
.cfi_offset 24, -40
\n
"
);
output
(
"
\t
stp x21, x22, [sp, #96]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 21, -64
\n
"
);
output_cfi
(
"
\t
.cfi_offset 22, -56
\n
"
);
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
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
"
);
output
(
"
\t
ldp x0, x1, [sp, #16]
\n
"
);
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
ldrb w9, [x16, x20]
\n
"
);
output
(
"
\t
subs x9, x9, #64
\n
"
);
output
(
"
\t
bls 2f
\n
"
);
output
(
"
\t
add x11, x29, #176
\n
"
);
output
(
"
\t
sub sp, sp, x9
\n
"
);
output
(
"
\t
tbz x9, #3, 1f
\n
"
);
output
(
"
\t
sub sp, sp, #8
\n
"
);
output
(
"1:
\t
sub x9, x9, #8
\n
"
);
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
(
"
\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
(
"
\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
(
"
\t
movk x0, #0x%x
\n
"
,
invalid_param
&
0x0000ffff
);
output
(
"
\t
ret
\n
"
);
break
;
default:
assert
(
0
);
}
output_cfi
(
".cfi_endproc"
);
output_function_size
(
"__wine_syscall_dispatcher"
);
}
/* output the functions for system calls */
void
output_syscalls
(
DLLSPEC
*
spec
)
{
const
unsigned
int
invalid_param
=
0xc000000d
;
/* STATUS_INVALID_PARAMETER */
int
i
,
count
;
ORDDEF
**
syscalls
=
NULL
;
...
...
@@ -1447,259 +1707,7 @@ void output_syscalls( DLLSPEC *spec )
if
(
unix_lib
)
{
output
(
"
\t
.align %d
\n
"
,
get_alignment
(
4
)
);
output
(
"
\t
%s
\n
"
,
func_declaration
(
"__wine_syscall_dispatcher"
)
);
output
(
"%s
\n
"
,
asm_globl
(
"__wine_syscall_dispatcher"
)
);
output_cfi
(
".cfi_startproc"
);
switch
(
target_cpu
)
{
case
CPU_x86
:
output
(
"
\t
pushl %%ebp
\n
"
);
output_cfi
(
".cfi_adjust_cfa_offset 4
\n
"
);
output_cfi
(
".cfi_rel_offset %%ebp,0
\n
"
);
output
(
"
\t
movl %%esp,%%ebp
\n
"
);
output_cfi
(
".cfi_def_cfa_register %%ebp
\n
"
);
output
(
"
\t
pushl %%ebx
\n
"
);
output_cfi
(
".cfi_rel_offset %%ebx,-4
\n
"
);
output
(
"
\t
pushl %%esi
\n
"
);
output_cfi
(
".cfi_rel_offset %%esi,-8
\n
"
);
output
(
"
\t
pushl %%edi
\n
"
);
output_cfi
(
".cfi_rel_offset %%edi,-12
\n
"
);
output
(
"
\t
movl %%esp,%%fs:0x1f8
\n
"
);
/* x86_thread_data()->syscall_frame */
output
(
"
\t
cmpl $%u,%%eax
\n
"
,
count
);
output
(
"
\t
jae 3f
\n
"
);
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
"
);
needs_get_pc_thunk
=
1
;
}
else
output
(
"
\t
movzbl .Lsyscall_args(%%eax),%%ecx
\n
"
);
output
(
"
\t
subl %%ecx,%%esp
\n
"
);
output
(
"
\t
shrl $2,%%ecx
\n
"
);
output
(
"
\t
leal 12(%%ebp),%%esi
\n
"
);
output
(
"
\t
andl $~15,%%esp
\n
"
);
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
leal -12(%%ebp),%%esp
\n
"
);
output
(
"2:
\t
movl $0,%%fs:0x1f8
\n
"
);
output
(
"
\t
popl %%edi
\n
"
);
output_cfi
(
".cfi_same_value %%edi
\n
"
);
output
(
"
\t
popl %%esi
\n
"
);
output_cfi
(
".cfi_same_value %%esi
\n
"
);
output
(
"
\t
popl %%ebx
\n
"
);
output_cfi
(
".cfi_same_value %%ebx
\n
"
);
output
(
"
\t
popl %%ebp
\n
"
);
output_cfi
(
".cfi_def_cfa %%esp,4
\n
"
);
output_cfi
(
".cfi_same_value %%ebp
\n
"
);
output
(
"
\t
ret
\n
"
);
output
(
"3:
\t
movl $0x%x,%%eax
\n
"
,
invalid_param
);
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
leaq -0x10(%%rbp),%%rsp
\n
"
);
output
(
"
\t
pushfq
\n
"
);
output
(
"
\t
subq $0x280,%%rsp
\n
"
);
output
(
"
\t
andq $~63,%%rsp
\n
"
);
output
(
"
\t
movq %%rbx,-0x90(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%rbx,-144"
);
output
(
"
\t
movq %%rsi,-0x78(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%rsi,-120"
);
output
(
"
\t
movq %%rdi,-0x70(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%rdi,-112"
);
output
(
"
\t
movq %%r12,-0x48(%%rbp)
\n
"
);
output_cfi
(
".cfi_rel_offset %%r12,-72"
);
output
(
"
\t
movq %%r13,-0x40(%%rbp)
\n
"
);
output
(
"
\t
movq %%r14,-0x38(%%rbp)
\n
"
);
output
(
"
\t
movq %%r15,-0x30(%%rbp)
\n
"
);
/* 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
movq 0x8(%%rbp),%%rbx
\n
"
);
output
(
"
\t
movq %%rbx,-0x28(%%rbp)
\n
"
);
output
(
"
\t
leaq 0x10(%%rbp),%%rbx
\n
"
);
output
(
"
\t
movq %%rbx,-0x10(%%rbp)
\n
"
);
output
(
"
\t
movw %%cs,-0x20(%%rbp)
\n
"
);
output
(
"
\t
movw %%ds,-0x1e(%%rbp)
\n
"
);
output
(
"
\t
movw %%es,-0x1c(%%rbp)
\n
"
);
output
(
"
\t
movw %%fs,-0x1a(%%rbp)
\n
"
);
output
(
"
\t
movw %%ss,-0x8(%%rbp)
\n
"
);
output
(
"
\t
movw %%gs,-0x6(%%rbp)
\n
"
);
output
(
"
\t
movq %%rsp,%%r12
\n
"
);
output
(
"
\t
fxsave64 (%%r12)
\n
"
);
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,%%rax
\n
"
,
count
);
output
(
"
\t
jae 3f
\n
"
);
output
(
"
\t
leaq .Lsyscall_args(%%rip),%%rcx
\n
"
);
output
(
"
\t
movzbl (%%rcx,%%rax),%%ecx
\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
callq *(%%r10,%%rax,8)
\n
"
);
output
(
"2:
\t
movq %%gs:0x30,%%rcx
\n
"
);
output
(
"
\t
movq $0,0x328(%%rcx)
\n
"
);
output
(
"
\t
fxrstor64 (%%r12)
\n
"
);
output
(
"
\t
movq -0x30(%%rbp),%%r15
\n
"
);
output
(
"
\t
movq -0x38(%%rbp),%%r14
\n
"
);
output
(
"
\t
movq -0x40(%%rbp),%%r13
\n
"
);
output
(
"
\t
movq -0x48(%%rbp),%%r12
\n
"
);
output_cfi
(
".cfi_same_value %%r12"
);
output
(
"
\t
movq -0x70(%%rbp),%%rdi
\n
"
);
output_cfi
(
".cfi_same_value %%rdi"
);
output
(
"
\t
movq -0x78(%%rbp),%%rsi
\n
"
);
output_cfi
(
".cfi_same_value %%rsi"
);
output
(
"
\t
movq -0x90(%%rbp),%%rbx
\n
"
);
output_cfi
(
".cfi_same_value %%rbx"
);
output
(
"
\t
leaq -0x28(%%rbp),%%rsp
\n
"
);
output_cfi
(
".cfi_def_cfa_register %%rsp"
);
output_cfi
(
".cfi_adjust_cfa_offset 40"
);
output
(
"
\t
movq (%%rbp),%%rbp
\n
"
);
output_cfi
(
".cfi_same_value %%rbp"
);
output
(
"
\t
iretq
\n
"
);
output
(
"3:
\t
movl $0x%x,%%eax
\n
"
,
invalid_param
);
output
(
"
\t
jmp 2b
\n
"
);
break
;
case
CPU_ARM
:
output
(
"
\t
push {r5-r11,lr}
\n
"
);
output
(
"
\t
add r6, sp, #40
\n
"
);
/* stack parameters */
output
(
"
\t
ldr r5, 6f+8
\n
"
);
output
(
"
\t
cmp r4, 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 */
output
(
"
\t
mrs ip, CPSR
\n
"
);
output
(
"
\t
str ip, [sp, #4]
\n
"
);
output
(
"
\t
str sp, [r7]
\n
"
);
/* syscall frame */
output
(
"
\t
ldr r5, 6f+4
\n
"
);
if
(
UsePIC
)
output
(
"1:
\t
add r5, pc
\n
"
);
output
(
"
\t
ldrb r5, [r5, r4]
\n
"
);
/* syscall args */
output
(
"
\t
subs r5, #16
\n
"
);
/* first 4 args are in registers */
output
(
"
\t
ble 3f
\n
"
);
output
(
"
\t
sub ip, sp, r5
\n
"
);
output
(
"
\t
and ip, #~7
\n
"
);
output
(
"
\t
mov sp, ip
\n
"
);
output
(
"2:
\t
subs r5, r5, #4
\n
"
);
output
(
"
\t
ldr ip, [r6, r5]
\n
"
);
output
(
"
\t
str ip, [sp, r5]
\n
"
);
output
(
"
\t
bgt 2b
\n
"
);
output
(
"3:
\t
ldr r5, 6f
\n
"
);
if
(
UsePIC
)
output
(
"4:
\t
add r5, pc
\n
"
);
output
(
"
\t
ldr ip, [r5, r4, lsl #2]
\n
"
);
/* syscall table */
output
(
"
\t
blx ip
\n
"
);
output
(
"
\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 {r5-r11,pc}
\n
"
);
output
(
"5:
\t
ldr r0, 6f+12
\n
"
);
output
(
"
\t
pop {r5-r11,pc}
\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
);
}
else
{
output
(
"6:
\t
.long .Lsyscall_table
\n
"
);
output
(
"
\t
.long .Lsyscall_args
\n
"
);
}
output
(
"
\t
.long %u
\n
"
,
count
);
output
(
"
\t
.long 0x%x
\n
"
,
invalid_param
);
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
"
);
output_cfi
(
"
\t
.cfi_offset 30, -152
\n
"
);
output
(
"
\t
mov x29, sp
\n
"
);
output_cfi
(
"
\t
.cfi_def_cfa_register 29
\n
"
);
output
(
"
\t
stp x27, x28, [sp, #144]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 27, -16
\n
"
);
output_cfi
(
"
\t
.cfi_offset 28, -8
\n
"
);
output
(
"
\t
stp x25, x26, [sp, #128]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 25, -32
\n
"
);
output_cfi
(
"
\t
.cfi_offset 26, -24
\n
"
);
output
(
"
\t
stp x23, x24, [sp, #112]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 23, -48
\n
"
);
output_cfi
(
"
\t
.cfi_offset 24, -40
\n
"
);
output
(
"
\t
stp x21, x22, [sp, #96]
\n
"
);
output_cfi
(
"
\t
.cfi_offset 21, -64
\n
"
);
output_cfi
(
"
\t
.cfi_offset 22, -56
\n
"
);
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
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
"
);
output
(
"
\t
ldp x0, x1, [sp, #16]
\n
"
);
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
ldrb w9, [x16, x20]
\n
"
);
output
(
"
\t
subs x9, x9, #64
\n
"
);
output
(
"
\t
bls 2f
\n
"
);
output
(
"
\t
add x11, x29, #176
\n
"
);
output
(
"
\t
sub sp, sp, x9
\n
"
);
output
(
"
\t
tbz x9, #3, 1f
\n
"
);
output
(
"
\t
sub sp, sp, #8
\n
"
);
output
(
"1:
\t
sub x9, x9, #8
\n
"
);
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
(
"
\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
(
"
\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
(
"
\t
movk x0, #0x%x
\n
"
,
invalid_param
&
0x0000ffff
);
output
(
"
\t
ret
\n
"
);
break
;
default:
assert
(
0
);
}
output_cfi
(
".cfi_endproc"
);
output_function_size
(
"__wine_syscall_dispatcher"
);
output_syscall_dispatcher
(
count
);
output
(
"
\t
.data
\n
"
);
output
(
"
\t
.align %d
\n
"
,
get_alignment
(
get_ptr_size
()
)
);
...
...
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