[PATCH] sh: fix __HAVE_SHARED__ condition in crti.S.

Takashi Yoshii yoshii.takashi at renesas.com
Tue Aug 19 04:47:29 UTC 2008


Hi,

For SH, init/fini function prologue is defined in libc/sysdeps/linux/sh/crti.S
as follows.

| (frame entry)
|#ifndef __HAVE_SHARED__
| (GOT pointer initialization)
|#endif

I think this should be "ifdef", but "ifndef".
Or, are there any reason that GOT should be used (only)in NON-shared case ?

I did some cleanups as well as invert that conditions.
Actually, "push r12" is not needed in non-shared case. But, I've left it
 untouched, because I don't want to modify the function epilogue(crtn.S).
If fixed, we will have 4 bytes smaller code. Anyone want it ?

Regards,
/yoshii
---
libc/sysdeps/linux/sh/crti.S:
  Fix(invert) __HAVE_SHARED__ condition.
  Reorder/eliminate instructions.

Signed-off-by: Takashi YOSHII <yoshii.takashi at renesas.com>
---
diff --git a/libc/sysdeps/linux/sh/crti.S b/libc/sysdeps/linux/sh/crti.S
index a74f96e..a092b78 100644
--- a/libc/sysdeps/linux/sh/crti.S
+++ b/libc/sysdeps/linux/sh/crti.S
@@ -12,20 +12,17 @@ _init:
 	mov.l	r12, at -r15
 	mov.l	r14, at -r15
 	sts.l	pr, at -r15
-#ifndef __HAVE_SHARED__
+	mov	r15,r14
+#ifdef __HAVE_SHARED__
 	mova	.L6,r0
 	mov.l	.L6,r12
-	add	r0,r12
-#endif	
-	mov	r15,r14
 	bra	1f
-	nop
+	add	r0,r12
 	.align 2
-#ifndef __HAVE_SHARED__
 .L6:
 	.long	_GLOBAL_OFFSET_TABLE_
-#endif
 1:
+#endif
 	
 	.section .fini
 	.hidden  _fini
@@ -37,19 +34,15 @@ _fini:
 	mov.l	r14, at -r15
 	sts.l	pr, at -r15
 	mov	r15,r14
-#ifndef __HAVE_SHARED__
+#ifdef __HAVE_SHARED__
 	mov.l	.L11,r12
 	mova	.L11,r0
-	add	r0,r12
-#endif	
-
 	bra	1f
-	nop
+	add	r0,r12
 	.align 2
-#ifndef __HAVE_SHARED__
 .L11:
 	.long	_GLOBAL_OFFSET_TABLE_
-#endif
 1:
+#endif
 	
 	.ident	"GCC: (GNU) 3.3.2"




More information about the uClibc mailing list