Browse Source

* proper initialization of library

git-svn-id: trunk@5832 -
florian 18 years ago
parent
commit
20dfbaee59
1 changed files with 12 additions and 10 deletions
  1. 12 10
      rtl/linux/x86_64/dllprt0.as

+ 12 - 10
rtl/linux/x86_64/dllprt0.as

@@ -33,6 +33,12 @@
 		...
 					NULL
 */
+.section .init
+	.align 16
+	.globl FPC_LIB_START
+	.type FPC_LIB_START,@function
+FPC_LIB_START:
+	jmp	_startlib@PLT
 
         .text
 	.globl _start
@@ -40,17 +46,13 @@
 _startlib:
 #       movq %rdx,%r9                 /* Address of the shared library termination
 #               	                 function.  */
-FPC_LIB_START:
-	popq     %rsi		      /* Pop the argument count.  */
+	pushq	 %rbx
         movq     operatingsystem_parameter_argc@GOTPCREL(%rip),%rbx
-        movq     %rsi,(%rbx)
+        movq     %rdi,(%rbx)
         movq     operatingsystem_parameter_argv@GOTPCREL(%rip),%rbx
-	movq     %rsp,(%rbx)          /* argv starts just at the current stack top.  */
-        leaq     8(,%rsi,8),%rax
-        addq     %rsp,%rax
+	movq     %rsi,(%rbx)          /* argv starts just at the current stack top.  */
         movq     operatingsystem_parameter_envp@GOTPCREL(%rip),%rbx
-        movq     %rax,(%rbx)
-        andq     $~15,%rsp            /* Align the stack to a 16 byte boundary to follow the ABI.  */
+        movq     %rdx,(%rbx)
 
         movq    TC_SYSTEM_ISLIBRARY@GOTPCREL(%rip),%rbx
         movb    $1,(%rbx)
@@ -59,9 +61,9 @@ FPC_LIB_START:
         movq    __stkptr@GOTPCREL(%rip),%rbx
         movq    %rsp,(%rbx)
 
-        xorq    %rbp, %rbp
         call    PASCALMAIN@PLT
-	call    _haltproc@PLT
+	popq	%rbx
+	ret
 
         .globl  _haltproc
         .type   _haltproc,@function