[uClibc-cvs] svn commit: trunk/uClibc/ldso/ldso/i386

jocke at uclibc.org jocke at uclibc.org
Sun Mar 20 23:18:29 UTC 2005


Author: jocke
Date: 2005-03-20 16:18:28 -0700 (Sun, 20 Mar 2005)
New Revision: 10046

Log:
Prepare for moving ldso FINI handling to libc by passing _dl_fini. This should not break ABI.
Minor cleanup as well.


Modified:
   trunk/uClibc/ldso/ldso/i386/dl-startup.h


Changeset:
Modified: trunk/uClibc/ldso/ldso/i386/dl-startup.h
===================================================================
--- trunk/uClibc/ldso/ldso/i386/dl-startup.h	2005-03-20 17:45:03 UTC (rev 10045)
+++ trunk/uClibc/ldso/ldso/i386/dl-startup.h	2005-03-20 23:18:28 UTC (rev 10046)
@@ -3,13 +3,23 @@
  * Architecture specific code used by dl-startup.c
  * Copyright (C) 2000-2004 by Erik Andersen <andersen at codepoet.org>
  */
-
 asm(
     "	.text\n"
+    "	.align 16\n"
     "	.globl	_start\n"
     "	.type	_start, at function\n"
     "_start:\n"
-    "	.set	_start,_dl_start\n"
+    "	call _dl_start\n"
+    "	# Save the user entry point address in %edi.\n"
+    "	movl %eax, %edi\n"
+    "	# Point %ebx at the GOT.\n"
+    "	call 1f\n"
+    "1:	popl	%ebx\n"
+    "	addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx\n"
+    "	# Pass our FINI ptr() to the user in %edx, as per ELF ABI.\n"
+    "	leal _dl_fini at GOTOFF(%ebx), %edx\n"
+    "	# Jump to the user's entry point.\n"
+    "	jmp *%edi\n"
     "	.size	_start,.-_start\n"
     "	.previous\n"
 );
@@ -17,7 +27,7 @@
 /* Get a pointer to the argv array.  On many platforms this can be just
  * the address if the first argument, on other platforms we need to
  * do something a little more subtle here.  */
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) & ARGS)
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) & ARGS)+1)
 
 /* Handle relocation of the symbols in the dynamic loader. */
 static inline
@@ -47,9 +57,4 @@
 /* Transfer control to the user's application, once the dynamic loader is
  * done.  This routine has to exit the current function, then call the
  * _dl_elf_main function.  */
-#define START() {							\
-	int status = 0;							\
-	__asm__ volatile ("leave\n\t"					\
-		    "jmp *%%eax\n\t"					\
-		    : "=a" (status) :	"a" (_dl_elf_main));		\
-}
+#define START() return _dl_elf_main




More information about the uClibc-cvs mailing list