mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 23:39:31 +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__:
|
||||
|
||||
.globl mainCRTStartup
|
||||
mainCRTStartup:
|
||||
@ EXE entry points
|
||||
.globl _mainCRTStartup
|
||||
_mainCRTStartup:
|
||||
mov r0,#1
|
||||
mov r3,#1
|
||||
b do_start
|
||||
|
||||
.globl WinMainCRTStartup
|
||||
WinMainCRTStartup:
|
||||
.globl _WinMainCRTStartup
|
||||
_WinMainCRTStartup:
|
||||
mov r0,#0
|
||||
mov r3,#0
|
||||
do_start:
|
||||
ldr r1, _PISCONSOLE
|
||||
strb r0,[r1]
|
||||
bl _FPC_EXE_Entry
|
||||
mov r0,#0
|
||||
ldr r12, _PISCONSOLE
|
||||
strb r3,[r12]
|
||||
b _FPC_EXE_Entry
|
||||
|
||||
@ 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:
|
||||
.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
|
||||
.section .pdata
|
||||
.word __EH_CODE_START__
|
||||
|
@ -23,6 +23,9 @@ interface
|
||||
|
||||
{$define WINCE_EXCEPTION_HANDLING}
|
||||
|
||||
{ Startup code }
|
||||
{$L wprt0.o}
|
||||
|
||||
{ include system-independent routine headers }
|
||||
{$I systemh.inc}
|
||||
|
||||
@ -60,7 +63,6 @@ var
|
||||
hprevinst,
|
||||
MainInstance,
|
||||
DLLreason,DLLparam:DWord;
|
||||
Win32StackTop : Dword; // Used by heaptrc unit
|
||||
|
||||
type
|
||||
TDLL_Process_Entry_Hook = function (dllparam : longint) : longbool;
|
||||
@ -756,8 +758,7 @@ end;
|
||||
|
||||
procedure PascalMain;stdcall;external name 'PASCALMAIN';
|
||||
procedure fpc_do_exit;stdcall;external name 'FPC_DO_EXIT';
|
||||
Procedure ExitDLL(Exitcode : longint); forward;
|
||||
procedure asm_exit(Exitcode : longint);external name 'asm_exit';
|
||||
procedure ExitThread(Exitcode : longint); external 'coredll';
|
||||
|
||||
Procedure system_exit;
|
||||
begin
|
||||
@ -766,14 +767,14 @@ begin
|
||||
the DLL exit code !!
|
||||
This crashes Win95 at least PM }
|
||||
if IsLibrary then
|
||||
ExitDLL(ExitCode);
|
||||
exit;
|
||||
// ExitDLL(ExitCode);
|
||||
if not IsConsole then begin
|
||||
Close(stderr);
|
||||
Close(stdout);
|
||||
{ what about Input and Output ?? PM }
|
||||
end;
|
||||
{ call exitprocess, with cleanup as required }
|
||||
asm_exit(exitcode);
|
||||
ExitThread(exitcode);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -796,59 +797,50 @@ function Dll_entry : longbool;[public, alias : '_FPC_DLL_Entry'];
|
||||
var
|
||||
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
|
||||
DLLExitOK:=ExitCode=0;
|
||||
LongJmp(DLLBuf,1);
|
||||
IsLibrary:=true;
|
||||
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;
|
||||
|
||||
{$ifdef WINCE_EXCEPTION_HANDLING}
|
||||
@ -1403,12 +1395,12 @@ begin
|
||||
{$ifdef CPUARM}
|
||||
asm
|
||||
mov fp,#0
|
||||
ldr r12,.LPWin32StackTop
|
||||
ldr r12,.LPStackTop
|
||||
str sp,[r12]
|
||||
bl PASCALMAIN;
|
||||
b .Lend
|
||||
.LPWin32StackTop:
|
||||
.long Win32StackTop
|
||||
.LPStackTop:
|
||||
.long StackTop
|
||||
.Lend:
|
||||
end;
|
||||
{$endif CPUARM}
|
||||
@ -1423,7 +1415,7 @@ begin
|
||||
pushl %ebp
|
||||
xorl %ebp,%ebp
|
||||
movl %esp,%eax
|
||||
movl %eax,Win32StackTop
|
||||
movl %eax,StackTop
|
||||
movw %ss,%bp
|
||||
movl %ebp,_SS
|
||||
call SysResetFPU
|
||||
@ -1640,13 +1632,9 @@ begin
|
||||
result := stklen;
|
||||
end;
|
||||
|
||||
const
|
||||
Exe_entry_code : pointer = @Exe_entry;
|
||||
Dll_entry_code : pointer = @Dll_entry;
|
||||
|
||||
begin
|
||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||
StackBottom := Sptr - StackLength;
|
||||
StackBottom := StackTop - StackLength;
|
||||
{ Enable FPU exceptions }
|
||||
_controlfp(1, $0008001F);
|
||||
{ some misc stuff }
|
||||
@ -1657,9 +1645,12 @@ begin
|
||||
{ Setup heap }
|
||||
InitHeap;
|
||||
SysInitExceptions;
|
||||
SysInitStdIO;
|
||||
{ Arguments }
|
||||
setup_arguments;
|
||||
if not IsLibrary then
|
||||
begin
|
||||
SysInitStdIO;
|
||||
{ Arguments }
|
||||
setup_arguments;
|
||||
end;
|
||||
{ Reset IO Error }
|
||||
InOutRes:=0;
|
||||
ProcessID := GetCurrentProcessID;
|
||||
|
Loading…
Reference in New Issue
Block a user