Browse Source

* partly reverted #38320, the code was correct

git-svn-id: trunk@38402 -
florian 7 years ago
parent
commit
05a92d55e4
2 changed files with 51 additions and 52 deletions
  1. 0 1
      rtl/linux/x86_64/gprt0.as
  2. 51 51
      rtl/linux/x86_64/si_g.inc

+ 0 - 1
rtl/linux/x86_64/gprt0.as

@@ -42,7 +42,6 @@ _start:
 	movq %rdx, %r9		/* Address of the shared library termination
 				   function.  */
 	popq %rsi		/* Pop the argument count.  */
-        pushq %rsi              /* keep stack aligned */
 	movq %rsp, %rdx		/* argv starts just at the current stack top.  */
 
         movq    entryinfo@GOTPCREL(%rip),%r10 /* load address of entryinfo variable */

+ 51 - 51
rtl/linux/x86_64/si_g.inc

@@ -53,10 +53,59 @@ procedure libc_start_main; external name '__libc_start_main';
 procedure gmon_monstartup; external name 'monstartup';
 procedure gmon_mcleanup; external name '_mcleanup';
 
-procedure main_stub; forward;
-
+procedure _FPC_libc_start; forward;
 procedure _FPC_libc_haltproc(e:longint); forward;
 
+ 
+procedure main_stub; assembler; nostackframe;
+  asm
+    { save return address }
+    popq    %rax
+
+    // stack alignment
+    pushq	%rax
+
+    movq    %rax,fpc_ret(%rip)
+    movq    %rbp,fpc_ret_rbp(%rip)
+    pushq   %rax
+
+    { Initialize gmon }
+    movq    _etext@GOTPCREL(%rip),%rsi
+    movq    _FPC_libc_start@GOTPCREL(%rip),%rdi
+    call    gmon_monstartup@PLT
+
+    movq    gmon_mcleanup@GOTPCREL(%rip),%rdi
+    call    libc_atexit@PLT
+
+{$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
+    movq    SysInitEntryInformation@GOTPCREL(%rip),%rdi
+
+    { Save initial stackpointer }
+    movq    %rsp,TEntryInformation.OS.stkptr(%rdi)
+
+    { store stack length }
+    movq    StackLength@GOTPCREL(%rip),%rax
+    movq    %rax,TEntryInformation.OS.stklen(%rdi)
+
+    { store pointer to haltproc }
+    movq    _FPC_libc_haltproc@GOTPCREL(%rip),%rax
+    movq    %rax,TEntryInformation.OS.haltproc(%rdi)
+
+    xorq    %rbp,%rbp
+    call    SysEntry@PLT
+{$else FPC_HAS_INDIRECT_ENTRY_INFORMATION}
+    { Save initial stackpointer }
+    movq    initialstkptr@GOTPCREL(%rip),%rax
+    movq    %rsp,(%rax)
+
+    { start the program }
+    xorq    %rbp,%rbp
+    call    PASCALMAIN@PLT
+{$endif FPC_HAS_INDIRECT_ENTRY_INFORMATION}
+    hlt
+  end;
+
+
 procedure ini_dummy;
   begin
   end;
@@ -88,7 +137,6 @@ procedure ini_dummy;
     movq %rdx, %r9          { Address of the shared library termination
                              function.  }
     popq %rsi               { Pop the argument count.  }
-    pushq %rsi              { keep stack aligned }
     movq %rsp, %rdx         { argv starts just at the current stack top.  }
 
 {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
@@ -150,54 +198,6 @@ procedure ini_dummy;
 *)
   end;
 
-procedure main_stub; assembler; nostackframe;
-  asm
-    { save return address }
-    popq    %rax
-
-    // stack alignment
-    pushq	%rax
-
-    movq    %rax,fpc_ret(%rip)
-    movq    %rbp,fpc_ret_rbp(%rip)
-    pushq   %rax
-
-    { Initialize gmon }
-    movq    _etext@GOTPCREL(%rip),%rsi
-    movq    _FPC_libc_start@GOTPCREL(%rip),%rdi
-    call    gmon_monstartup@PLT
-
-    movq    gmon_mcleanup@GOTPCREL(%rip),%rdi
-    call    libc_atexit@PLT
-
-{$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
-    movq    SysInitEntryInformation@GOTPCREL(%rip),%rdi
-
-    { Save initial stackpointer }
-    movq    %rsp,TEntryInformation.OS.stkptr(%rdi)
-
-    { store stack length }
-    movq    StackLength@GOTPCREL(%rip),%rax
-    movq    %rax,TEntryInformation.OS.stklen(%rdi)
-
-    { store pointer to haltproc }
-    movq    _FPC_libc_haltproc@GOTPCREL(%rip),%rax
-    movq    %rax,TEntryInformation.OS.haltproc(%rdi)
-
-    xorq    %rbp,%rbp
-    call    SysEntry@PLT
-{$else FPC_HAS_INDIRECT_ENTRY_INFORMATION}
-    { Save initial stackpointer }
-    movq    initialstkptr@GOTPCREL(%rip),%rax
-    movq    %rsp,(%rax)
-
-    { start the program }
-    xorq    %rbp,%rbp
-    call    PASCALMAIN@PLT
-{$endif FPC_HAS_INDIRECT_ENTRY_INFORMATION}
-    hlt
-  end;
-
 procedure _FPC_libc_haltproc(e:longint); assembler; nostackframe; public name '_haltproc';
   asm
     movl %edi,%eax