Browse Source

Cleaned up the assembler code a little.

Peter Kjellerstedt 19 năm trước cách đây
mục cha
commit
9ce85441f8
3 tập tin đã thay đổi với 73 bổ sung86 xóa
  1. 29 31
      libc/sysdeps/linux/cris/crt1.S
  2. 25 32
      libc/sysdeps/linux/cris/crti.S
  3. 19 23
      libc/sysdeps/linux/cris/crtn.S

+ 29 - 31
libc/sysdeps/linux/cris/crt1.S

@@ -2,28 +2,30 @@
 
 #include <features.h>
 
+	.syntax no_register_prefix
+
 /* The first piece of initialized data.  */
-.data
-.global __data_start
-.align 2
-.type	__data_start, @object
-.size	__data_start, 4
+	.data
+	.global	__data_start
+	.align	2
+	.type	__data_start, @object
+	.size	__data_start, 4
 __data_start:
 	.dword	0
 
-.text
-.align 1
-.global _start
-.type   _start,%function
+	.text
+	.align	1
+	.global	_start
+	.type	_start, %function
 #if defined(__UCLIBC_CTOR_DTOR__)
-.type   _init,%function
-.type   _fini,%function
+	.type	_init, %function
+	.type	_fini, %function
 #else
-.weak   _init
-.weak   _fini
+	.weak	_init
+	.weak	_fini
 #endif
-.type   main,%function
-.type   __uClibc_main,%function
+	.type	main, %function
+	.type	__uClibc_main, %function
 
 /*
  * On the stack we have argc. We can calculate argv/envp
@@ -39,20 +41,16 @@ __data_start:
  */
 
 _start:
-	pop $r10
-	move.d $sp, $r11
-	jump .L1
-
-.L1:
-	Push $srp
-	Subq 4,$sp
-	move.d $r10,$r9
-	move.d $r11,$r12
-	move.d _fini,$r13
-	move.d $r13,[$sp]
-	move.d main,$r10
-	move.d $r9,$r11
-	move.d _init,$r13
+	move.d	main, r10
+	move.d	[sp+], r11
+	move.d	sp, r12
+	subq	4, sp
+	move	srp, [sp]
+	subq	4, sp
+	move.d	_fini, r13
+	move.d	r13, [sp]
+	move.d	_init, r13
 	/* Leave control to the libc */
-	jsr __uClibc_main
-.size _start,.-_start
+	jsr	__uClibc_main
+	nop
+	.size	_start, .-_start

+ 25 - 32
libc/sysdeps/linux/cris/crti.S

@@ -1,36 +1,29 @@
-#NO_APP
-	.file	"initfini.c"
-#APP
-	
-	.section .init
-#NO_APP
-	.align 1
-	.global _init
+/* glibc's sysdeps/cris/elf/initfini.c used for reference [PROLOG] */
+
+	.section	.init
+	.align	1
+	.global	_init
 	.type	_init, @function
 _init:
-	Push $srp
-	subq 4,$sp
-	movem $r0,[$sp]
-	move.d $pc,$r0
-	sub.d .:GOTOFF,$r0
-#APP
-	
-	.align 1
-	
-	
-	.section .fini
-#NO_APP
-	.align 1
-	.global _fini
+	subq	4,$sp
+	move.d	$r1,[$sp]
+	move	$srp,$r1
+	subq	4,$sp
+	move.d	$r0,[$sp]
+	move.d	$pc,$r0
+	sub.d	.:GOTOFF,$r0
+	.align	1
+
+	.section	.fini
+	.align	1
+	.global	_fini
 	.type	_fini, @function
 _fini:
-	Push $srp
-	subq 4,$sp
-	movem $r0,[$sp]
-	move.d $pc,$r0
-	sub.d .:GOTOFF,$r0
-#APP
-	.align 1
-	
-	
-/*@TRAILER_BEGINS*/
+	subq	4,$sp
+	move.d	$r1,[$sp]
+	move	$srp,$r1
+	subq	4,$sp
+	move.d	$r0,[$sp]
+	move.d	$pc,$r0
+	sub.d	.:GOTOFF,$r0
+	.align	1

+ 19 - 23
libc/sysdeps/linux/cris/crtn.S

@@ -1,27 +1,23 @@
-#NO_APP
-	.file	"initfini.c"
-#APP
-	
-	.section .init
-#NO_APP
-	.align 1
-	.global _init
+/* glibc's sysdeps/cris/elf/initfini.c used for reference [EPILOG] */
+
+	.section	.init
+	.align	1
+	.global	_init
 	.type	_init, @function
-#NO_APP
-	movem [$sp+],$r0
-	Jump [$sp+]
+	move.d	[$sp+],$r0
+	move	$r1,$srp
+	move.d	[$sp+],$r1
+	Ret
+	nop
 	.size	_init, .-_init
-#APP
-	
-	.section .fini
-#NO_APP
-	.align 1
-	.global _fini
+
+	.section	.fini
+	.align	1
+	.global	_fini
 	.type	_fini, @function
-#NO_APP
-	movem [$sp+],$r0
-	Jump [$sp+]
+	move.d	[$sp+],$r0
+	move	$r1,$srp
+	move.d	[$sp+],$r1
+	Ret
+	nop
 	.size	_fini, .-_fini
-#APP
-	
-/*@TRAILER_BEGINS*/