[uClibc]SH initfini.awk problems ?

M. R. Brown mrbrown at 0xd6.org
Thu Oct 31 12:44:15 UTC 2002


* Stefan Allius <allius at atecom.com> on Thu, Oct 31, 2002:

> Hi,
> 
> I attached a new patch.
> I hope this will run fine.
> 

Unfortunately if fails with:

sh4-linux-gcc -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -Os -fno-builtin -fPIC -c crti.S -o crti.o
initfini.c: Assembler messages:
initfini.c:23: Error: unknown pseudo-op: `.l5'
initfini.c:46: Error: unknown pseudo-op: `.l10'
make[4]: *** [crti.o] Error 1

I've attached the patch - I had to clean it up for current CVS - as well as
the generated files.  I'm sorry I can't be of more help, but I still don't
fully understand what the bug is and I certainly don't understand awk
enough to fix it properly :P

M. R.
-------------- next part --------------
Index: extra/scripts/initfini.awk
===================================================================
RCS file: /var/cvs/uClibc/extra/scripts/initfini.awk,v
retrieving revision 1.3
diff -u -3 -p -u -r1.3 initfini.awk
--- extra/scripts/initfini.awk	2002/10/29 12:00:28	1.3
+++ extra/scripts/initfini.awk	2002/10/31 12:34:14
@@ -18,20 +18,27 @@ BEGIN \
     if(/\.end/) {end=1}
     if(/\.align/) {alignval=$2}
 # here comes some special stuff for the SuperH targets
-# Search for all labels
-#    if(/_GLOBAL_OFFSET_TABLE_/) {
-#      sub (":","",last);
-#      glb_label[glb_idx] = last;
-#      glb_idx += 1;
-#      glb = $0;
-#    }
+#  We search for all labels, which uses the _GLOBAL_OFFSET_TABLE_
+#  definition, and store them in the glb_label array.
+    if(/_GLOBAL_OFFSET_TABLE_/) {
+      sub (":","",last);
+      glb_label[glb_idx] = last;
+      glb_idx += 1;
+      glb = $0;
+    }
     last = $1;
   }
   close("initfini.s");
 }
 
-/^_init:/{omitcrtn=1;if (glb_idx>0) print glb_label[0] ":" glb >> "crti.S";}
-/^_fini:/{omitcrtn=1;if (glb_idx>1) print glb_label[1] ":" glb >> "crti.S";}
+# special rules for the SuperH targets (They do nothing on other targets)
+/SH_GLB_BEGINS/ && glb_idx==0 {omitcrti +=1}
+/_init_SH_GLB/  && glb_idx>=1 {print glb_label[0] glb >> "crti.S"}
+/_fini_SH_GLB/  && glb_idx>=2 {print glb_label[1] glb >> "crti.S"}
+/SH_GLB_ENDS/   && glb_idx==0 {omitcrti -=1}
+/SH_GLB/ || /_GLOBAL_OFFSET_TABLE_/{getline}
+
+# rules for all targets
 /HEADER_ENDS/{omitcrti=1;omitcrtn=1;getline}
 /PROLOG_BEGINS/{omitcrti=0;omitcrtn=0;getline}
 /i_am_not_a_leaf/{getline}
Index: libc/sysdeps/linux/common/initfini.c
===================================================================
RCS file: /var/cvs/uClibc/libc/sysdeps/linux/common/initfini.c,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 initfini.c
--- libc/sysdeps/linux/common/initfini.c	2002/10/29 11:25:10	1.10
+++ libc/sysdeps/linux/common/initfini.c	2002/10/31 12:34:15
@@ -52,6 +52,23 @@
 #  define HIDDEN(func)
 #endif
 
+#if defined(__sh__)
+  /* The macro insert this sh specific stuff:
+     @_SH_GLB_BEGINS
+          bra     1f
+	  nop
+	  ALIGN
+     @func_SH_GLB_LABEL
+     1:
+     @_SH_GLB_ENDS
+   */
+#define GLB_STUFF(func)  asm ("\n/*@_SH_GLB_BEGINS*/"); \
+  asm ("\n\tbra\t1f\n\tnop\n\tALIGN\n/*@" #func"_SH_GLB_LABEL*/\n1:"); \
+  asm ("\n/*@_SH_GLB_ENDS*/");
+#else
+#define GLB_STUFF(func)
+#endif
+
 /* The initial common code ends here. */
 asm ("\n/*@HEADER_ENDS*/");
 
@@ -107,6 +124,7 @@ void _init (void)
   asm ("\n/*@_init_PROLOG_UNPAUSES*/");
 #endif
 
+  GLB_STUFF(_init)
   asm ("ALIGN");
   asm("END_INIT");
   /* Now the epilog. */
@@ -127,6 +145,7 @@ void _fini (void)
 {
 
   /* End of the _fini prolog. */
+  GLB_STUFF(_fini)
   asm ("ALIGN");
   asm ("END_FINI");
   asm ("\n/*@_fini_PROLOG_ENDS*/");
-------------- next part --------------
	.file	"initfini.c"
	.text
	.little
	
/*@HEADER_ENDS*/
	.text
	.align 1
	.global	dummy
	.type	dummy, at function
dummy:
	mov.l	r14, at -r15
	tst	r4,r4
	sts.l	pr, at -r15
	bt/s	.L1
	mov	r15,r14
	jsr	@r4
	nop
.L1:
	mov	r14,r15
	lds.l	@r15+,pr
	rts	
	mov.l	@r15+,r14
.Lfe1:
	.size	dummy,.Lfe1-dummy
	
/*@_init_PROLOG_BEGINS*/
	.section .init
	.align 1
	.global	_init
	.type	_init, at function
_init:
	mov.l	r12, at -r15
	mova	.L5,r0
	mov.l	r14, at -r15
	mov.l	.L5,r12
	sts.l	pr, at -r15
	add	r0,r12
	mov	r15,r14
	
/*@_init_PROLOG_PAUSES*/
	mov.l	.L6,r1
	bsrf	r1
.LPCS0:
	nop
	
/*@_init_PROLOG_UNPAUSES*/
	
/*@_SH_GLB_BEGINS*/
	
	bra	1f
	nop
	ALIGN
/*@_init_SH_GLB_LABEL*/
1:
	
/*@_SH_GLB_ENDS*/
	ALIGN
	END_INIT
	
/*@_init_PROLOG_ENDS*/
	
/*@_init_EPILOG_BEGINS*/
	mov	r14,r15
	lds.l	@r15+,pr
	mov.l	@r15+,r14
	rts	
	mov.l	@r15+,r12
.L7:
	.align 2
.L5:
	.long	_GLOBAL_OFFSET_TABLE_
.L6:
	.long	i_am_not_a_leaf at PLT-(.LPCS0+2-(.))
.Lfe2:
	.size	_init,.Lfe2-_init
	
/*@_init_EPILOG_ENDS*/
	
/*@_fini_PROLOG_BEGINS*/
	.section .fini
	.align 1
	.global	_fini
	.type	_fini, at function
_fini:
	mov.l	r12, at -r15
	mova	.L10,r0
	mov.l	r14, at -r15
	mov.l	.L10,r12
	sts.l	pr, at -r15
	add	r0,r12
	mov	r15,r14
	
/*@_SH_GLB_BEGINS*/
	
	bra	1f
	nop
	ALIGN
/*@_fini_SH_GLB_LABEL*/
1:
	
/*@_SH_GLB_ENDS*/
	ALIGN
	END_FINI
	
/*@_fini_PROLOG_ENDS*/
	mov.l	.L11,r1
	bsrf	r1
.LPCS1:
	nop
	
/*@_fini_EPILOG_BEGINS*/
	mov	r14,r15
	lds.l	@r15+,pr
	mov.l	@r15+,r14
	rts	
	mov.l	@r15+,r12
.L12:
	.align 2
.L10:
	.long	_GLOBAL_OFFSET_TABLE_
.L11:
	.long	i_am_not_a_leaf2 at PLT-(.LPCS1+2-(.))
.Lfe3:
	.size	_fini,.Lfe3-_fini
	
/*@_fini_EPILOG_ENDS*/
	
/*@TRAILER_BEGINS*/
	.ident	"GCC: (GNU) 3.2"
-------------- next part --------------
	.file	"initfini.c"
	.text
	.little
	
	.section .init
	.align 1
	.global	_init
	.type	_init, at function
_init:
	mov.l	r12, at -r15
	mova	.L5b,r0
	mov.l	r14, at -r15
	mov.l	.L5b,r12
	sts.l	pr, at -r15
	add	r0,r12
	mov	r15,r14
	
	
	
	bra	1f
	nop
	.align 2
.L5	.long	_GLOBAL_OFFSET_TABLE_
1:
	
	.align 2
	
	
	.section .fini
	.align 1
	.global	_fini
	.type	_fini, at function
_fini:
	mov.l	r12, at -r15
	mova	.L10b,r0
	mov.l	r14, at -r15
	mov.l	.L10b,r12
	sts.l	pr, at -r15
	add	r0,r12
	mov	r15,r14
	
	
	bra	1f
	nop
	.align 2
.L10	.long	_GLOBAL_OFFSET_TABLE_
1:
	
	.align 2
	
	
	.ident	"GCC: (GNU) 3.2"
-------------- next part --------------
	.file	"initfini.c"
	.text
	.little
	
	.section .init
	.align 1
	.global	_init
	.type	_init, at function
_init:
	mov.l	r12, at -r15
	mova	.L5b,r0
	mov.l	r14, at -r15
	mov.l	.L5b,r12
	sts.l	pr, at -r15
	add	r0,r12
	mov	r15,r14
	
	mov.l	.L6,r1
	bsrf	r1
.LPCS0:
	nop
	
	
	
	bra	1f
	nop
	.align 2
1:
	
	.align 2
	
	
	
	mov	r14,r15
	lds.l	@r15+,pr
	mov.l	@r15+,r14
	rts	
	mov.l	@r15+,r12
.L7:
	.align 2
.L5b:
.L6:
.Lfe2:
	.size	_init,.Lfe2-_init
	
	.section .fini
	.align 1
	.global	_fini
	.type	_fini, at function
_fini:
	mov.l	r12, at -r15
	mova	.L10b,r0
	mov.l	r14, at -r15
	mov.l	.L10b,r12
	sts.l	pr, at -r15
	add	r0,r12
	mov	r15,r14
	
	
	bra	1f
	nop
	.align 2
1:
	
	.align 2
	
	
	mov.l	.L11,r1
	bsrf	r1
.LPCS1:
	nop
	
	mov	r14,r15
	lds.l	@r15+,pr
	mov.l	@r15+,r14
	rts	
	mov.l	@r15+,r12
.L12:
	.align 2
.L10b:
.L11:
.Lfe3:
	.size	_fini,.Lfe3-_fini
	
	.ident	"GCC: (GNU) 3.2"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20021031/90499cc8/attachment.pgp 


More information about the uClibc mailing list