summary refs log tree commit diff
path: root/sysdeps/sparc/sparc32
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>1998-04-06 17:40:58 +0000
committerRichard Henderson <rth@redhat.com>1998-04-06 17:40:58 +0000
commita55400166da3b4713ea9258be7ee739bdbd2d607 (patch)
treea76e856fa728c047fe54f3259238ed8a91b46035 /sysdeps/sparc/sparc32
parentdeb2f929b59710d946e0a32dc3f49e4f0d4ed25d (diff)
downloadglibc-a55400166da3b4713ea9258be7ee739bdbd2d607.tar.gz
glibc-a55400166da3b4713ea9258be7ee739bdbd2d607.tar.xz
glibc-a55400166da3b4713ea9258be7ee739bdbd2d607.zip
* sysdeps/sparc/sparc32/elf.S: Rewrite for __libc_start_main. * sysdeps/sparc/sparc64/elf.S: Likewise.
	* sysdeps/sparc/sparc32/elf.S: Rewrite for __libc_start_main.
	* sysdeps/sparc/sparc64/elf.S: Likewise.

1998-04-06  Richard Henderson  <rth@cygnus.com>
Diffstat (limited to 'sysdeps/sparc/sparc32')
-rw-r--r--sysdeps/sparc/sparc32/elf/start.S68
1 files changed, 21 insertions, 47 deletions
diff --git a/sysdeps/sparc/sparc32/elf/start.S b/sysdeps/sparc/sparc32/elf/start.S
index 24715e68be..d45e0cedf4 100644
--- a/sysdeps/sparc/sparc32/elf/start.S
+++ b/sysdeps/sparc/sparc32/elf/start.S
@@ -1,5 +1,5 @@
 /* Startup code for elf32-sparc
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,56 +31,30 @@ _start:
 	mov	%g0, %fp
 	sub	%sp, 6*4, %sp
 
-  /* Save %g1.  When starting a binary via the dynamic linker, %g1
-     contains the address of the shared library termination function,
-     which we will register below with atexit() to be called by exit().
-     If we are statically linked, this will be NULL.  */
-
-  /* Do essential libc initialization (sp points to argc, argv, and envp)  */
-	call	__libc_init_first
-	 mov	%g1, %l0
-
-  /* Now that we have the proper stack frame, register library termination
-     function, if there is any:  */
-
-	cmp	%l0, 0
-	beq	1f
-	 nop
-	call	atexit
-	 mov	%l0, %o0
-1:
-
   /* Extract the arguments and environment as encoded on the stack.  The
      argument info starts after one register window (16 words) past the SP.  */
-	ld	[%sp+22*4], %o0
-	add	%sp, 23*4, %o1
-	sll	%o0, 2, %o2
-	add	%o2, %o1, %o2
-	sethi	%hi(__environ), %g2
-	add	%o2, 4, %o2
-	st	%o2, [%g2+%lo(__environ)]
-
-	mov	%o0, %l0		/* tuck them away */
-	mov	%o1, %l1
-
-  /* Call _init, the entry point to our own .init section.  */
-	call	_init
-	 mov	%o2, %l2
-
-  /* Register our .fini section with atexit.  */
-	sethi	%hi(_fini), %o0
-	call	atexit
-	 add	%o0, %lo(_fini), %o0
-
-  /* Call the user's main and exit with its return value.  */
-	mov	%l0, %o0
-	mov	%l1, %o1
-	call	main
-	 mov	%l2, %o2
-	call	exit
+	ld	[%sp+22*4], %o1
+	add	%sp, 23*4, %o2
+
+  /* Load the addresses of the user entry points.  */
+	sethi	%hi(main), %o0
+	sethi	%hi(_init), %o3
+	sethi	%hi(_fini), %o4
+	or	%o0, %lo(main), %o0
+	or	%o3, %lo(_init), %o3
+	or	%o4, %lo(_fini), %o4
+
+  /* When starting a binary via the dynamic linker, %g1 contains the
+     address of the shared library termination function, which will be
+     registered with atexit().  If we are statically linked, this will
+     be NULL.  */
+	mov	%g1, %o5
+
+  /* Let libc do the rest of the initialization, and call main.  */
+	call	__libc_start_main
 	 nop
 
   /* Die very horribly if exit returns.  */
 	unimp
 
-	.size _start,.-_start
+	.size _start, .-_start