mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 15:05:58 +02:00
* fixes for smartlinking
This commit is contained in:
parent
c7637424cf
commit
e2904b82a1
@ -28,11 +28,9 @@ interface
|
|||||||
{ include heap support headers }
|
{ include heap support headers }
|
||||||
{$I heaph.inc}
|
{$I heaph.inc}
|
||||||
|
|
||||||
{ifdef debug removed (PM)}
|
|
||||||
{$ifdef i386}
|
{$ifdef i386}
|
||||||
{$define Set_i386_Exception_handler}
|
{$define Set_i386_Exception_handler}
|
||||||
{$endif i386}
|
{$endif i386}
|
||||||
{endif debug}
|
|
||||||
|
|
||||||
const
|
const
|
||||||
{ Default filehandles }
|
{ Default filehandles }
|
||||||
@ -711,48 +709,66 @@ end;
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
procedure install_exception_handlers;forward;
|
procedure install_exception_handlers;forward;
|
||||||
|
|
||||||
{$ASMMODE DIRECT}
|
|
||||||
var
|
var
|
||||||
{ value of the stack segment
|
{ value of the stack segment
|
||||||
to check if the call stack can be written on exceptions }
|
to check if the call stack can be written on exceptions }
|
||||||
_SS : longint;
|
_SS : longint;
|
||||||
|
|
||||||
procedure Exe_entry;[public, alias : '_FPC_EXE_Entry'];
|
procedure Exe_entry;[public, alias : '_FPC_EXE_Entry'];
|
||||||
begin
|
begin
|
||||||
IsLibrary:=false;
|
IsLibrary:=false;
|
||||||
{ install the handlers for exe only ?
|
{ install the handlers for exe only ?
|
||||||
or should we install them for DLL also ? (PM) }
|
or should we install them for DLL also ? (PM) }
|
||||||
install_exception_handlers;
|
install_exception_handlers;
|
||||||
|
{ This strange construction is needed to solve the _SS problem
|
||||||
|
with a smartlinked syswin32 (PFV) }
|
||||||
|
{$ASMMODE ATT}
|
||||||
asm
|
asm
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
xorl %ebp,%ebp
|
xorl %ebp,%ebp
|
||||||
movw %ss,%bp
|
movw %ss,%bp
|
||||||
movl %ebp,__SS
|
movl %ebp,_SS
|
||||||
xorl %ebp,%ebp
|
xorl %ebp,%ebp
|
||||||
|
end;
|
||||||
|
{$ASMMODE DIRECT}
|
||||||
|
asm
|
||||||
call PASCALMAIN
|
call PASCALMAIN
|
||||||
popl %ebp
|
popl %ebp
|
||||||
end;
|
end;
|
||||||
{ if we pass here there was no error ! }
|
{ if we pass here there was no error ! }
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure Dll_entry;[public, alias : '_FPC_DLL_Entry'];
|
procedure Dll_entry;[public, alias : '_FPC_DLL_Entry'];
|
||||||
begin
|
begin
|
||||||
IsLibrary:=true;
|
IsLibrary:=true;
|
||||||
case DLLreason of
|
case DLLreason of
|
||||||
1,2 : asm
|
1,2 :
|
||||||
xorl %edi,%edi
|
begin
|
||||||
movw %ss,%di
|
{$ASMMODE ATT}
|
||||||
movl %edi,__SS
|
asm
|
||||||
call PASCALMAIN
|
xorl %edi,%edi
|
||||||
end;
|
movw %ss,%di
|
||||||
|
movl %edi,_SS
|
||||||
|
end;
|
||||||
|
{$ASMMODE DIRECT}
|
||||||
|
asm
|
||||||
|
call PASCALMAIN
|
||||||
|
end;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
asm
|
begin
|
||||||
|
asm
|
||||||
call FPC_DO_EXIT
|
call FPC_DO_EXIT
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{$ASMMODE ATT}
|
||||||
|
|
||||||
|
|
||||||
{$ifdef Set_i386_Exception_handler}
|
{$ifdef Set_i386_Exception_handler}
|
||||||
|
|
||||||
@ -828,7 +844,7 @@ const
|
|||||||
TCONTEXT = CONTEXT;
|
TCONTEXT = CONTEXT;
|
||||||
PCONTEXT = ^CONTEXT;
|
PCONTEXT = ^CONTEXT;
|
||||||
|
|
||||||
|
|
||||||
type pexception_record = ^exception_record;
|
type pexception_record = ^exception_record;
|
||||||
EXCEPTION_RECORD = record
|
EXCEPTION_RECORD = record
|
||||||
ExceptionCode : longint;
|
ExceptionCode : longint;
|
||||||
@ -847,11 +863,11 @@ type pexception_record = ^exception_record;
|
|||||||
|
|
||||||
{ type of functions that should be used for exception handling }
|
{ type of functions that should be used for exception handling }
|
||||||
LPTOP_LEVEL_EXCEPTION_FILTER = function(excep :PEXCEPTION_POINTERS) : longint;
|
LPTOP_LEVEL_EXCEPTION_FILTER = function(excep :PEXCEPTION_POINTERS) : longint;
|
||||||
|
|
||||||
function SetUnhandledExceptionFilter(lpTopLevelExceptionFilter : LPTOP_LEVEL_EXCEPTION_FILTER)
|
function SetUnhandledExceptionFilter(lpTopLevelExceptionFilter : LPTOP_LEVEL_EXCEPTION_FILTER)
|
||||||
: LPTOP_LEVEL_EXCEPTION_FILTER;
|
: LPTOP_LEVEL_EXCEPTION_FILTER;
|
||||||
external 'kernel32' name 'SetUnhandledExceptionFilter';
|
external 'kernel32' name 'SetUnhandledExceptionFilter';
|
||||||
|
|
||||||
function syswin32_i386_exception_handler(excep :PEXCEPTION_POINTERS) : longint;
|
function syswin32_i386_exception_handler(excep :PEXCEPTION_POINTERS) : longint;
|
||||||
var frame : longint;
|
var frame : longint;
|
||||||
begin
|
begin
|
||||||
@ -893,29 +909,27 @@ type pexception_record = ^exception_record;
|
|||||||
{EXCEPTION_INVALID_DISPOSITION = $c0000026;}
|
{EXCEPTION_INVALID_DISPOSITION = $c0000026;}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
old_exception : LPTOP_LEVEL_EXCEPTION_FILTER;
|
old_exception : LPTOP_LEVEL_EXCEPTION_FILTER;
|
||||||
|
|
||||||
procedure install_exception_handlers;
|
procedure install_exception_handlers;
|
||||||
begin
|
begin
|
||||||
old_exception:=SetUnhandledExceptionFilter(@syswin32_i386_exception_handler);
|
old_exception:=SetUnhandledExceptionFilter(@syswin32_i386_exception_handler);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$else not i386 (Processor specific !!)}
|
{$else not i386 (Processor specific !!)}
|
||||||
procedure install_exception_handlers;
|
procedure install_exception_handlers;
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$endif Set_i386_Exception_handler}
|
{$endif Set_i386_Exception_handler}
|
||||||
|
|
||||||
const
|
const
|
||||||
Exe_entry_code : pointer = @Exe_entry;
|
Exe_entry_code : pointer = @Exe_entry;
|
||||||
Dll_entry_code : pointer = @Dll_entry;
|
Dll_entry_code : pointer = @Dll_entry;
|
||||||
|
|
||||||
{$ASMMODE ATT}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ get some helpful informations }
|
{ get some helpful informations }
|
||||||
@ -952,7 +966,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.31 1998-12-28 15:50:51 peter
|
Revision 1.32 1998-12-28 23:30:11 peter
|
||||||
|
* fixes for smartlinking
|
||||||
|
|
||||||
|
Revision 1.31 1998/12/28 15:50:51 peter
|
||||||
+ stdout, which is needed when you write something in the system unit
|
+ stdout, which is needed when you write something in the system unit
|
||||||
to the screen. Like the runtime error
|
to the screen. Like the runtime error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user