mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 23:29:13 +02:00
* Linker error fixed.
* DLL support for wince. Still one issue: DLLs can not do console i/o. * StackTop support. git-svn-id: trunk@2754 -
This commit is contained in:
parent
21d7670a0b
commit
c93aeb8e04
@ -11,67 +11,37 @@ __EH_HANDLER__:
|
|||||||
|
|
||||||
__EH_CODE_START__:
|
__EH_CODE_START__:
|
||||||
|
|
||||||
.globl mainCRTStartup
|
@ EXE entry points
|
||||||
mainCRTStartup:
|
|
||||||
.globl _mainCRTStartup
|
.globl _mainCRTStartup
|
||||||
_mainCRTStartup:
|
_mainCRTStartup:
|
||||||
mov r0,#1
|
mov r3,#1
|
||||||
b do_start
|
b do_start
|
||||||
|
|
||||||
.globl WinMainCRTStartup
|
|
||||||
WinMainCRTStartup:
|
|
||||||
.globl _WinMainCRTStartup
|
.globl _WinMainCRTStartup
|
||||||
_WinMainCRTStartup:
|
_WinMainCRTStartup:
|
||||||
mov r0,#0
|
mov r3,#0
|
||||||
do_start:
|
do_start:
|
||||||
ldr r1, _PISCONSOLE
|
ldr r12, _PISCONSOLE
|
||||||
strb r0,[r1]
|
strb r3,[r12]
|
||||||
bl _FPC_EXE_Entry
|
b _FPC_EXE_Entry
|
||||||
mov r0,#0
|
|
||||||
|
@ DLL entry points
|
||||||
|
.globl _DLLMainCRTStartup
|
||||||
|
_DLLMainCRTStartup:
|
||||||
|
mov r3,#1
|
||||||
|
b do_start2
|
||||||
|
|
||||||
|
.globl _DLLWinMainCRTStartup
|
||||||
|
_DLLWinMainCRTStartup:
|
||||||
|
mov r3,#0
|
||||||
|
do_start2:
|
||||||
|
ldr r12, _PISCONSOLE
|
||||||
|
strb r3,[r12]
|
||||||
|
b _FPC_DLLMainStartup
|
||||||
|
|
||||||
.globl asm_exit
|
|
||||||
asm_exit:
|
|
||||||
bl exitthread
|
|
||||||
|
|
||||||
_PISCONSOLE:
|
_PISCONSOLE:
|
||||||
.long U_SYSTEM_ISCONSOLE
|
.long U_SYSTEM_ISCONSOLE
|
||||||
|
|
||||||
.globl exitthread
|
|
||||||
exitthread:
|
|
||||||
ldr ip,.L100
|
|
||||||
ldr pc,[ip]
|
|
||||||
.L100:
|
|
||||||
.long .L10
|
|
||||||
|
|
||||||
.section .idata$2
|
|
||||||
.rva .L7
|
|
||||||
.long 0,0
|
|
||||||
.rva .L6
|
|
||||||
.rva .L8
|
|
||||||
|
|
||||||
.section .idata$4
|
|
||||||
.L7:
|
|
||||||
.rva .L9
|
|
||||||
.long 0
|
|
||||||
|
|
||||||
.section .idata$5
|
|
||||||
.L8:
|
|
||||||
|
|
||||||
.section .idata$5
|
|
||||||
.L10:
|
|
||||||
.rva .L9
|
|
||||||
.long 0
|
|
||||||
|
|
||||||
.section .idata$6
|
|
||||||
.L9:
|
|
||||||
.short 0
|
|
||||||
.ascii "ExitThread\000"
|
|
||||||
.balign 2,0
|
|
||||||
|
|
||||||
.section .idata$7
|
|
||||||
.L6:
|
|
||||||
.ascii "coredll.dll\000"
|
|
||||||
|
|
||||||
@ for kernel exception handler
|
@ for kernel exception handler
|
||||||
.section .pdata
|
.section .pdata
|
||||||
.word __EH_CODE_START__
|
.word __EH_CODE_START__
|
||||||
|
@ -23,6 +23,9 @@ interface
|
|||||||
|
|
||||||
{$define WINCE_EXCEPTION_HANDLING}
|
{$define WINCE_EXCEPTION_HANDLING}
|
||||||
|
|
||||||
|
{ Startup code }
|
||||||
|
{$L wprt0.o}
|
||||||
|
|
||||||
{ include system-independent routine headers }
|
{ include system-independent routine headers }
|
||||||
{$I systemh.inc}
|
{$I systemh.inc}
|
||||||
|
|
||||||
@ -60,7 +63,6 @@ var
|
|||||||
hprevinst,
|
hprevinst,
|
||||||
MainInstance,
|
MainInstance,
|
||||||
DLLreason,DLLparam:DWord;
|
DLLreason,DLLparam:DWord;
|
||||||
Win32StackTop : Dword; // Used by heaptrc unit
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TDLL_Process_Entry_Hook = function (dllparam : longint) : longbool;
|
TDLL_Process_Entry_Hook = function (dllparam : longint) : longbool;
|
||||||
@ -756,8 +758,7 @@ end;
|
|||||||
|
|
||||||
procedure PascalMain;stdcall;external name 'PASCALMAIN';
|
procedure PascalMain;stdcall;external name 'PASCALMAIN';
|
||||||
procedure fpc_do_exit;stdcall;external name 'FPC_DO_EXIT';
|
procedure fpc_do_exit;stdcall;external name 'FPC_DO_EXIT';
|
||||||
Procedure ExitDLL(Exitcode : longint); forward;
|
procedure ExitThread(Exitcode : longint); external 'coredll';
|
||||||
procedure asm_exit(Exitcode : longint);external name 'asm_exit';
|
|
||||||
|
|
||||||
Procedure system_exit;
|
Procedure system_exit;
|
||||||
begin
|
begin
|
||||||
@ -766,14 +767,14 @@ begin
|
|||||||
the DLL exit code !!
|
the DLL exit code !!
|
||||||
This crashes Win95 at least PM }
|
This crashes Win95 at least PM }
|
||||||
if IsLibrary then
|
if IsLibrary then
|
||||||
ExitDLL(ExitCode);
|
exit;
|
||||||
|
// ExitDLL(ExitCode);
|
||||||
if not IsConsole then begin
|
if not IsConsole then begin
|
||||||
Close(stderr);
|
Close(stderr);
|
||||||
Close(stdout);
|
Close(stdout);
|
||||||
{ what about Input and Output ?? PM }
|
{ what about Input and Output ?? PM }
|
||||||
end;
|
end;
|
||||||
{ call exitprocess, with cleanup as required }
|
ExitThread(exitcode);
|
||||||
asm_exit(exitcode);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -796,59 +797,50 @@ function Dll_entry : longbool;[public, alias : '_FPC_DLL_Entry'];
|
|||||||
var
|
var
|
||||||
res : longbool;
|
res : longbool;
|
||||||
|
|
||||||
begin
|
|
||||||
IsLibrary:=true;
|
|
||||||
Dll_entry:=false;
|
|
||||||
case DLLreason of
|
|
||||||
DLL_PROCESS_ATTACH :
|
|
||||||
begin
|
|
||||||
If SetJmp(DLLBuf) = 0 then
|
|
||||||
begin
|
|
||||||
if assigned(Dll_Process_Attach_Hook) then
|
|
||||||
begin
|
|
||||||
res:=Dll_Process_Attach_Hook(DllParam);
|
|
||||||
if not res then
|
|
||||||
exit(false);
|
|
||||||
end;
|
|
||||||
PASCALMAIN;
|
|
||||||
Dll_entry:=true;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Dll_entry:=DLLExitOK;
|
|
||||||
end;
|
|
||||||
DLL_THREAD_ATTACH :
|
|
||||||
begin
|
|
||||||
inc(Thread_count);
|
|
||||||
{$warning Allocate Threadvars !}
|
|
||||||
if assigned(Dll_Thread_Attach_Hook) then
|
|
||||||
Dll_Thread_Attach_Hook(DllParam);
|
|
||||||
Dll_entry:=true; { return value is ignored }
|
|
||||||
end;
|
|
||||||
DLL_THREAD_DETACH :
|
|
||||||
begin
|
|
||||||
dec(Thread_count);
|
|
||||||
if assigned(Dll_Thread_Detach_Hook) then
|
|
||||||
Dll_Thread_Detach_Hook(DllParam);
|
|
||||||
{$warning Release Threadvars !}
|
|
||||||
Dll_entry:=true; { return value is ignored }
|
|
||||||
end;
|
|
||||||
DLL_PROCESS_DETACH :
|
|
||||||
begin
|
|
||||||
Dll_entry:=true; { return value is ignored }
|
|
||||||
If SetJmp(DLLBuf) = 0 then
|
|
||||||
begin
|
|
||||||
FPC_DO_EXIT;
|
|
||||||
end;
|
|
||||||
if assigned(Dll_Process_Detach_Hook) then
|
|
||||||
Dll_Process_Detach_Hook(DllParam);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Procedure ExitDLL(Exitcode : longint);
|
|
||||||
begin
|
begin
|
||||||
DLLExitOK:=ExitCode=0;
|
IsLibrary:=true;
|
||||||
LongJmp(DLLBuf,1);
|
Dll_entry:=false;
|
||||||
|
case DLLreason of
|
||||||
|
DLL_PROCESS_ATTACH :
|
||||||
|
begin
|
||||||
|
if assigned(Dll_Process_Attach_Hook) then
|
||||||
|
begin
|
||||||
|
res:=Dll_Process_Attach_Hook(DllParam);
|
||||||
|
if not res then
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
|
PASCALMAIN;
|
||||||
|
Dll_entry:=true;
|
||||||
|
end;
|
||||||
|
DLL_THREAD_ATTACH :
|
||||||
|
begin
|
||||||
|
inc(Thread_count);
|
||||||
|
{$warning Allocate Threadvars !}
|
||||||
|
if assigned(Dll_Thread_Attach_Hook) then
|
||||||
|
Dll_Thread_Attach_Hook(DllParam);
|
||||||
|
end;
|
||||||
|
DLL_THREAD_DETACH :
|
||||||
|
begin
|
||||||
|
dec(Thread_count);
|
||||||
|
if assigned(Dll_Thread_Detach_Hook) then
|
||||||
|
Dll_Thread_Detach_Hook(DllParam);
|
||||||
|
{$warning Release Threadvars !}
|
||||||
|
end;
|
||||||
|
DLL_PROCESS_DETACH :
|
||||||
|
begin
|
||||||
|
FPC_DO_EXIT;
|
||||||
|
if assigned(Dll_Process_Detach_Hook) then
|
||||||
|
Dll_Process_Detach_Hook(DllParam);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DLLMainStartup(_hinstance,_dllreason,_dllparam:longint);stdcall;public name '_FPC_DLLMainStartup';
|
||||||
|
begin
|
||||||
|
sysinstance:=_hinstance;
|
||||||
|
dllreason:=_dllreason;
|
||||||
|
dllparam:=_dllparam;
|
||||||
|
DLL_Entry;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef WINCE_EXCEPTION_HANDLING}
|
{$ifdef WINCE_EXCEPTION_HANDLING}
|
||||||
@ -1403,12 +1395,12 @@ begin
|
|||||||
{$ifdef CPUARM}
|
{$ifdef CPUARM}
|
||||||
asm
|
asm
|
||||||
mov fp,#0
|
mov fp,#0
|
||||||
ldr r12,.LPWin32StackTop
|
ldr r12,.LPStackTop
|
||||||
str sp,[r12]
|
str sp,[r12]
|
||||||
bl PASCALMAIN;
|
bl PASCALMAIN;
|
||||||
b .Lend
|
b .Lend
|
||||||
.LPWin32StackTop:
|
.LPStackTop:
|
||||||
.long Win32StackTop
|
.long StackTop
|
||||||
.Lend:
|
.Lend:
|
||||||
end;
|
end;
|
||||||
{$endif CPUARM}
|
{$endif CPUARM}
|
||||||
@ -1423,7 +1415,7 @@ begin
|
|||||||
pushl %ebp
|
pushl %ebp
|
||||||
xorl %ebp,%ebp
|
xorl %ebp,%ebp
|
||||||
movl %esp,%eax
|
movl %esp,%eax
|
||||||
movl %eax,Win32StackTop
|
movl %eax,StackTop
|
||||||
movw %ss,%bp
|
movw %ss,%bp
|
||||||
movl %ebp,_SS
|
movl %ebp,_SS
|
||||||
call SysResetFPU
|
call SysResetFPU
|
||||||
@ -1640,13 +1632,9 @@ begin
|
|||||||
result := stklen;
|
result := stklen;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
Exe_entry_code : pointer = @Exe_entry;
|
|
||||||
Dll_entry_code : pointer = @Dll_entry;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||||
StackBottom := Sptr - StackLength;
|
StackBottom := StackTop - StackLength;
|
||||||
{ Enable FPU exceptions }
|
{ Enable FPU exceptions }
|
||||||
_controlfp(1, $0008001F);
|
_controlfp(1, $0008001F);
|
||||||
{ some misc stuff }
|
{ some misc stuff }
|
||||||
@ -1657,9 +1645,12 @@ begin
|
|||||||
{ Setup heap }
|
{ Setup heap }
|
||||||
InitHeap;
|
InitHeap;
|
||||||
SysInitExceptions;
|
SysInitExceptions;
|
||||||
SysInitStdIO;
|
if not IsLibrary then
|
||||||
{ Arguments }
|
begin
|
||||||
setup_arguments;
|
SysInitStdIO;
|
||||||
|
{ Arguments }
|
||||||
|
setup_arguments;
|
||||||
|
end;
|
||||||
{ Reset IO Error }
|
{ Reset IO Error }
|
||||||
InOutRes:=0;
|
InOutRes:=0;
|
||||||
ProcessID := GetCurrentProcessID;
|
ProcessID := GetCurrentProcessID;
|
||||||
|
Loading…
Reference in New Issue
Block a user