mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-22 19:39:29 +01:00
+ adds mcount calls to syscall assembler helpers for i386 and x86-64, resolves #17140
git-svn-id: trunk@15812 -
This commit is contained in:
parent
da77c0c190
commit
7dc4b6ecc1
@ -634,6 +634,15 @@ end;
|
|||||||
function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; compilerproc;
|
function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; compilerproc;
|
||||||
begin
|
begin
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
cld
|
cld
|
||||||
movl __RESULT,%edi
|
movl __RESULT,%edi
|
||||||
movl sstr,%esi
|
movl sstr,%esi
|
||||||
@ -671,6 +680,15 @@ procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring)
|
|||||||
var
|
var
|
||||||
saveesi,saveedi : longint;
|
saveesi,saveedi : longint;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movl %edi,saveedi
|
movl %edi,saveedi
|
||||||
movl %esi,saveesi
|
movl %esi,saveesi
|
||||||
cld
|
cld
|
||||||
@ -714,6 +732,15 @@ procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring)
|
|||||||
procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
|
procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
|
||||||
begin
|
begin
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
pushl %eax
|
pushl %eax
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
cld
|
cld
|
||||||
@ -759,6 +786,15 @@ end;
|
|||||||
function fpc_shortstr_concat(const s1,s2:shortstring):shortstring;compilerproc;
|
function fpc_shortstr_concat(const s1,s2:shortstring):shortstring;compilerproc;
|
||||||
begin
|
begin
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movl __RESULT,%edi
|
movl __RESULT,%edi
|
||||||
movl %edi,%ebx
|
movl %edi,%ebx
|
||||||
movl s1,%esi { first string }
|
movl s1,%esi { first string }
|
||||||
@ -821,6 +857,15 @@ procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring);
|
|||||||
[public,alias:'FPC_SHORTSTR_APPEND_SHORTSTR'];
|
[public,alias:'FPC_SHORTSTR_APPEND_SHORTSTR'];
|
||||||
begin
|
begin
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movl s1,%edi
|
movl s1,%edi
|
||||||
movl s2,%esi
|
movl s2,%esi
|
||||||
movl %edi,%ebx
|
movl %edi,%ebx
|
||||||
@ -866,6 +911,15 @@ function fpc_shortstr_compare(const left,right:shortstring): longint;assembler;
|
|||||||
var
|
var
|
||||||
saveesi,saveedi,saveebx : longint;
|
saveesi,saveedi,saveebx : longint;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movl %edi,saveedi
|
movl %edi,saveedi
|
||||||
movl %esi,saveesi
|
movl %esi,saveesi
|
||||||
movl %ebx,saveebx
|
movl %ebx,saveebx
|
||||||
@ -930,6 +984,15 @@ procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);assembler;[public
|
|||||||
var
|
var
|
||||||
saveres,saveebx,saveesi,saveedi : longint;
|
saveres,saveebx,saveesi,saveedi : longint;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movl %ebx,saveebx
|
movl %ebx,saveebx
|
||||||
movl %esi,saveesi
|
movl %esi,saveesi
|
||||||
movl %edi,saveedi
|
movl %edi,saveedi
|
||||||
@ -1031,6 +1094,15 @@ function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LE
|
|||||||
var
|
var
|
||||||
saveedi : longint;
|
saveedi : longint;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movl %edi,saveedi
|
movl %edi,saveedi
|
||||||
{$ifdef REGCALL}
|
{$ifdef REGCALL}
|
||||||
movl %eax,%edi
|
movl %eax,%edi
|
||||||
@ -1123,6 +1195,15 @@ const digits:array[0..9] of cardinal=(0,10,100,1000,10000,
|
|||||||
100000000,1000000000);
|
100000000,1000000000);
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %esi
|
push %esi
|
||||||
push %edi
|
push %edi
|
||||||
push %ebx
|
push %ebx
|
||||||
|
|||||||
@ -77,9 +77,18 @@ end;
|
|||||||
|
|
||||||
Procedure fpc_geteipasebx;[external name 'fpc_geteipasebx'];
|
Procedure fpc_geteipasebx;[external name 'fpc_geteipasebx'];
|
||||||
|
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
procedure mcount; external name 'mcount';
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
|
|
||||||
function FpSysCall(sysnr:TSysParam):TSysResult; assembler; register; [public,alias:'FPC_SYSCALL0'];
|
function FpSysCall(sysnr:TSysParam):TSysResult; assembler; register; [public,alias:'FPC_SYSCALL0'];
|
||||||
{ Var sysnr located in register eax }
|
{ Var sysnr located in register eax }
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
call mcount
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %ecx
|
push %ecx
|
||||||
{$ifdef FPC_PIC}
|
{$ifdef FPC_PIC}
|
||||||
@ -118,6 +127,13 @@ function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler; register; [p
|
|||||||
{ Var sysnr located in register eax
|
{ Var sysnr located in register eax
|
||||||
Var param1 located in register edx }
|
Var param1 located in register edx }
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
call mcount
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %ecx
|
push %ecx
|
||||||
{$ifdef FPC_PIC}
|
{$ifdef FPC_PIC}
|
||||||
@ -160,6 +176,15 @@ function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler; regis
|
|||||||
Var param1 located in register edx
|
Var param1 located in register edx
|
||||||
Var param2 located in register ecx }
|
Var param2 located in register ecx }
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %edx
|
push %edx
|
||||||
push %ecx
|
push %ecx
|
||||||
@ -208,6 +233,15 @@ function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;
|
|||||||
var
|
var
|
||||||
_psysinfo: LongWord;
|
_psysinfo: LongWord;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %edx
|
push %edx
|
||||||
push %ecx
|
push %ecx
|
||||||
@ -261,6 +295,15 @@ function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; asse
|
|||||||
var
|
var
|
||||||
_psysinfo: LongWord;
|
_psysinfo: LongWord;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %esi
|
push %esi
|
||||||
push %ecx
|
push %ecx
|
||||||
@ -318,6 +361,15 @@ function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysRes
|
|||||||
var
|
var
|
||||||
_psysinfo: LongWord;
|
_psysinfo: LongWord;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %edx
|
push %edx
|
||||||
push %esi
|
push %esi
|
||||||
@ -383,6 +435,15 @@ function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6: TSysParam):T
|
|||||||
var
|
var
|
||||||
_psysinfo: LongWord;
|
_psysinfo: LongWord;
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
push %eax
|
||||||
|
push %edx
|
||||||
|
push %ecx
|
||||||
|
call mcount
|
||||||
|
pop %ecx
|
||||||
|
pop %edx
|
||||||
|
pop %eax
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
push %ebx
|
push %ebx
|
||||||
push %edx
|
push %edx
|
||||||
push %esi
|
push %esi
|
||||||
|
|||||||
@ -17,9 +17,18 @@
|
|||||||
|
|
||||||
{$ASMMODE GAS}
|
{$ASMMODE GAS}
|
||||||
|
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
procedure mcount; external name 'mcount';
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
|
|
||||||
function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
|
function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
call mcount
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
syscall { Do the system call. }
|
syscall { Do the system call. }
|
||||||
cmpq $-4095, %rax { Check %rax for error. }
|
cmpq $-4095, %rax { Check %rax for error. }
|
||||||
@ -52,6 +61,13 @@ end;
|
|||||||
function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
|
function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
pushq param1
|
||||||
|
call mcount
|
||||||
|
popq param1
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
movq param1, %rdi { shift arg1 - arg5. }
|
movq param1, %rdi { shift arg1 - arg5. }
|
||||||
syscall { Do the system call. }
|
syscall { Do the system call. }
|
||||||
@ -85,6 +101,15 @@ end;
|
|||||||
function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
|
function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
pushq param1
|
||||||
|
pushq param2
|
||||||
|
call mcount
|
||||||
|
popq param2
|
||||||
|
popq param1
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
movq param1, %rdi { shift arg1 - arg5. }
|
movq param1, %rdi { shift arg1 - arg5. }
|
||||||
movq param2, %rsi
|
movq param2, %rsi
|
||||||
@ -119,6 +144,17 @@ end;
|
|||||||
function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
|
function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
pushq param1
|
||||||
|
pushq param2
|
||||||
|
pushq param3
|
||||||
|
call mcount
|
||||||
|
popq param3
|
||||||
|
popq param2
|
||||||
|
popq param1
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
movq param1, %rdi { shift arg1 - arg5. }
|
movq param1, %rdi { shift arg1 - arg5. }
|
||||||
movq param2, %rsi
|
movq param2, %rsi
|
||||||
@ -154,6 +190,19 @@ end;
|
|||||||
function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
|
function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
pushq param1
|
||||||
|
pushq param2
|
||||||
|
pushq param3
|
||||||
|
pushq param4
|
||||||
|
call mcount
|
||||||
|
popq param4
|
||||||
|
popq param3
|
||||||
|
popq param2
|
||||||
|
popq param1
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
movq param1, %rdi { shift arg1 - arg5. }
|
movq param1, %rdi { shift arg1 - arg5. }
|
||||||
movq param2, %rsi
|
movq param2, %rsi
|
||||||
@ -190,6 +239,21 @@ end;
|
|||||||
function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
|
function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
pushq param1
|
||||||
|
pushq param2
|
||||||
|
pushq param3
|
||||||
|
pushq param4
|
||||||
|
pushq param5
|
||||||
|
call mcount
|
||||||
|
popq param5
|
||||||
|
popq param4
|
||||||
|
popq param3
|
||||||
|
popq param2
|
||||||
|
popq param1
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
movq param1, %rdi { shift arg1 - arg5. }
|
movq param1, %rdi { shift arg1 - arg5. }
|
||||||
movq param2, %rsi
|
movq param2, %rsi
|
||||||
@ -228,6 +292,23 @@ end;
|
|||||||
function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
|
function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
|
||||||
|
|
||||||
asm
|
asm
|
||||||
|
{$ifdef FPC_PROFILE}
|
||||||
|
pushq sysnr
|
||||||
|
pushq param1
|
||||||
|
pushq param2
|
||||||
|
pushq param3
|
||||||
|
pushq param4
|
||||||
|
pushq param5
|
||||||
|
pushq param6
|
||||||
|
call mcount
|
||||||
|
popq param6
|
||||||
|
popq param5
|
||||||
|
popq param4
|
||||||
|
popq param3
|
||||||
|
popq param2
|
||||||
|
popq param1
|
||||||
|
popq sysnr
|
||||||
|
{$endif FPC_PROFILE}
|
||||||
movq sysnr, %rax { Syscall number -> rax. }
|
movq sysnr, %rax { Syscall number -> rax. }
|
||||||
movq param1, %rdi { shift arg1 - arg5. }
|
movq param1, %rdi { shift arg1 - arg5. }
|
||||||
movq param2, %rsi
|
movq param2, %rsi
|
||||||
@ -268,3 +349,4 @@ end;
|
|||||||
{$IFDEF SYS_LINUX}
|
{$IFDEF SYS_LINUX}
|
||||||
{$UNDEF SYSCALL_DEBUG}
|
{$UNDEF SYSCALL_DEBUG}
|
||||||
{$ENDIF SYS_LINUX}
|
{$ENDIF SYS_LINUX}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user