Browse Source

Adjust the C-less entry points to support indirect main information.

rtl/inc/si_dll.inc:
  * _FPC_shared_lib_start: fill in SysInitEntryInformation and call SysEntry with it in case of indirect main information
rtl/inc/si_prc.inc:
  * _FPC_proc_start: fill in SysInitEntryInformation and call SysEntyr with it in case of indirect main information

git-svn-id: branches/svenbarth/packages@32488 -
svenbarth 9 years ago
parent
commit
12f0ae4949
2 changed files with 56 additions and 3 deletions
  1. 11 1
      rtl/linux/i386/si_dll.inc
  2. 45 2
      rtl/linux/i386/si_prc.inc

+ 11 - 1
rtl/linux/i386/si_dll.inc

@@ -13,6 +13,7 @@
  **********************************************************************}
 {$asmmode att}
 
+procedure _FPC_shared_lib_haltproc(e: longint); cdecl; forward;
 
 {******************************************************************************
                         Shared library start/halt
@@ -20,13 +21,22 @@
 
 procedure _FPC_shared_lib_start(argc : dword;argv,envp : pointer); cdecl; public name 'FPC_SHARED_LIB_START'; public name '_start';
 begin
-
+{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}
+  SysInitEntryInformation.Platform.argc:=argc;
+  SysInitEntryInformation.Platform.argv:=argv;
+  SysInitEntryInformation.Platform.envp:=envp;
+  SysInitEntryInformation.Platform.stkptr:=get_frame;
+  SysInitEntryInformation.Platform.haltproc:=@_FPC_shared_lib_haltproc;
+
+  SysEntry(SysInitEntryInformation);
+{$else}
   operatingsystem_parameter_argc:=argc;    { Copy the argument count      }
   operatingsystem_parameter_argv:=argv;    { Copy the argument pointer    }
   operatingsystem_parameter_envp:=envp;    { Copy the environment pointer }
   initialstkptr:=get_frame;
 
   PASCALMAIN;
+{$endif}
 end;
 
 { this routine is only called when the halt() routine of the RTL embedded in

+ 45 - 2
rtl/linux/i386/si_prc.inc

@@ -34,6 +34,8 @@
          argc <--- esp
 }
 
+procedure _FPC_proc_haltproc(e: longint); cdecl; forward;
+
 {******************************************************************************
                           Process start/halt
  ******************************************************************************}
@@ -55,6 +57,7 @@ asm
   leal    4(%esp,%ecx,4),%eax     { The start of the environment is: esp+4*eax+4 }
   andl    $0xfffffff0,%esp        { Align stack to 16 bytes }
 
+  {$ifndef FPC_HAS_INDIRECT_MAIN_INFORMATION}
   {$ifdef FPC_PIC}
         pushl %ebx
         pushl %ecx
@@ -93,8 +96,48 @@ asm
   	movl    %esp,initialstkptr
   {$endif FPC_PIC}
 
-  xorl    %ebp,%ebp
-  call    PASCALMAIN
+        xorl    %ebp,%ebp
+        call    PASCALMAIN
+  {$else FPC_HAS_INDIRECT_MAIN_INFORMATION}
+  {$ifdef FPC_PIC}
+        pushl   %ebx
+        pushl   %ecx
+
+        call    fpc_geteipasebxlocal
+        addl    $_GLOBAL_OFFSET_TABLE_,%ebx
+
+        movl    SysInitEntryInformation@GOT(%ebx),%ecx
+        movl    %eax,SysInitEntryInformation.Platform.envp(%ebx)
+
+        popl    %eax
+        movl    %eax,SysInitEntryInformation.Platform.argc(%ebx)
+
+        popl    %eax
+        movl    %eax,SysInitEntryInformation.Platform.argv(%ebx)
+
+        leal    _FPC_proc_haltproc,%eax
+        movl    %eax,SysInitEntryInformation.Platform.haltproc(%ebx)
+
+        call    SysResetFPU
+
+        movl    %esp,SysInitEntryInformation.Platform.stkptr(%ebx)
+
+        movl    %ebx,%eax
+  {$else FPC_PIC}
+        movl    %eax,SysInitEntryInformation.Platform.envp
+        movl    %ecx,SysInitEntryInformation.Platform.argc
+        movl    %ebx,SysInitEntryInformation.Platform.argv
+        leal    _FPC_proc_haltproc,%eax
+        movl    %eax,SysInitEntryInformation.Platform.haltproc;
+
+        call    SysResetFPU
+
+        movl    %esp,SysInitEntryInformation.Platform.stkptr
+        lea     SysInitEntryInformation,%eax
+  {$endif FPC_PIC}
+        xorl    %ebp,%ebp
+        call    SysEntry
+  {$endif FPC_HAS_INDIRECT_MAIN_INFORMATION}
 end;
 
 procedure _FPC_dynamic_proc_start; assembler; nostackframe; public name '_dynamic_start';