[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

r1278 - in trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64: . elf



Author: ps-guest
Date: 2006-02-28 20:21:50 +0000 (Tue, 28 Feb 2006)
New Revision: 1278

Modified:
   trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/dl-machine.h
   trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/elf/start.S
Log:
* yet another change for _startup calling convention 
  now also static binaries should work fine



Modified: trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/dl-machine.h
===================================================================
--- trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/dl-machine.h	2006-02-28 17:32:32 UTC (rev 1277)
+++ trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/dl-machine.h	2006-02-28 20:21:50 UTC (rev 1278)
@@ -66,10 +66,12 @@
 	xorl %ebp, %ebp\n\
 	# Call the function to run the initializers.\n\
 	call _dl_init_internal@PLT\n\
-	# Pass our finalizer function to the user in %rdx, as per ELF ABI.\n\
+	# Pass our finalizer function to the user in %rdx, as per ELF ABI draft.\n\
 	leaq _dl_fini(%rip), %rdx\n\
 	# And make sure %rdi points to argc stored on the stack.\n\
 	movq %r13, %rdi\n\
+	# Pass finalizer function also in %rsi, as per C calling convention.\n\
+	movq %rdx, %rsi\n\
 	# Jump to the user's entry point.\n\
 	jmp *%r12\n\
 .previous\n\

Modified: trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/elf/start.S
===================================================================
--- trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/elf/start.S	2006-02-28 17:32:32 UTC (rev 1277)
+++ trunk/glibc-2.3-head/sysdeps/kfreebsd/x86_64/elf/start.S	2006-02-28 20:21:50 UTC (rev 1278)
@@ -39,7 +39,7 @@
 /* This is the canonical entry point, usually the first thing in the text
    segment.  The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
    point runs, most registers' values are unspecified, except for a few.
-   Applied on amd64:
+   Blindly applied on amd64:
 
    %rdx		Contains a function pointer to be registered with `atexit'.
 		This is how the dynamic linker arranges to have DT_FINI
@@ -55,10 +55,21 @@
 		...
 					NULL
 
-   On amd64 %rsp also have to be 16-byte aligned,
-   FreeBSD decided to use %edi as pointer to stack and align %rsp,
-   therefore on entry from system, %rsp=%rdi or %rsp=%rdi-8.
-   on entry from ld.so glibc might set up it slightly differently 
+   But on amd64 %rsp also have to be 16-byte aligned, 
+   standard C calling convention already passes arguments in registers.
+
+   FreeBSD uses %edi as pointer to arguments and environment, %rsp is passed aligned.
+   On entry from kernel, %rsp=%rdi or %rsp=%rdi-8,
+   on entry from ld.so, glibc might set up it slightly differently.
+
+   On FreeBSD, we use %rsi for passing function pointer to rtld_fini().
+   On entry from FreeBSD kernel, %rsi is cleared, %rdx is not cleared,
+   on entry from ld.so, glibc sets both %rsi and %rdx to point to rtld_fini().
+
+   Used interface (via %rdi, %rsi) is equal to standard C calling interface for
+
+   void _start(void *arg, void *rtld_fini());
+
 */
 
 #include "bp-sym.h"
@@ -85,7 +96,7 @@
 	rtld_fini:	%r9
 	stack_end:	stack.	*/
 
-	movq %rdx, %r9		/* Address of the shared library termination
+	movq %rsi, %r9		/* Address of the shared library termination
 				   function.  */
 	movq 0(%rdi), %rsi	/* argument count.  */
 	leaq 8(%rdi), %rdx      /* argv starts just at above argc.  */



Reply to: