Subject: removing init/fini_fallthru
To: None <tech-toolchain@netbsd.org>
From: Simon Burge <simonb@NetBSD.org>
List: tech-toolchain
Date: 06/20/2006 00:38:30
MIPS with gcc4 is having some problems generating bad code which we sort
of worked around but breaking gcc3 in the process.  Nick Hudson and I
have come up with the following which does away with the init_fallthru
and fini_fallthru functions and just puts _init and _fini directly in
the .init and .fini sections.  I've tested this with gcc4 and Nick has
tested this with gcc3 and c++ and threaded programs work fine.

Further to this, is there any reason why we should use init_fallthru and
fini_fallthru on any architecture and not this method?

Cheers,
Simon.

Index: lib/csu/common_elf/crti.c
===================================================================
RCS file: /cvsroot/src/lib/csu/common_elf/crti.c,v
retrieving revision 1.3
diff -d -p -u -r1.3 crti.c
--- lib/csu/common_elf/crti.c	19 May 2006 19:11:12 -0000	1.3
+++ lib/csu/common_elf/crti.c	19 Jun 2006 14:29:15 -0000
@@ -43,6 +43,7 @@
 #include "sysident.h"
 #include <dot_init.h>
 
+#ifndef MD_DO_NOT_NEED_FALLTHRU
 INIT_FALLTHRU_DECL;
 FINI_FALLTHRU_DECL;
 
@@ -62,6 +63,7 @@ _fini(void)
 
 	FINI_FALLTHRU();
 }
+#endif /* MD_DO_NOT_NEED_FALLTHRU */
 
 MD_INIT_SECTION_PROLOGUE;
 MD_FINI_SECTION_PROLOGUE;
Index: lib/csu/mips/dot_init.h
===================================================================
RCS file: /cvsroot/src/lib/csu/mips/dot_init.h,v
retrieving revision 1.5
diff -d -p -u -r1.5 dot_init.h
--- lib/csu/mips/dot_init.h	12 Jun 2006 22:05:49 -0000	1.5
+++ lib/csu/mips/dot_init.h	19 Jun 2006 14:29:15 -0000
@@ -36,17 +36,6 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-/*
- * These must be extern to avoid warnings ("declared static but never defined")
- * However, only the declaration is extern, the actually __asm() defines them
- * as static.
- */
-#define	INIT_FALLTHRU_DECL void init_fallthru(void)
-#define	FINI_FALLTHRU_DECL void fini_fallthru(void)
-
-#define	INIT_FALLTHRU()	init_fallthru()
-#define	FINI_FALLTHRU()	fini_fallthru()
-
 #define	ra	"$31"
 
 /*
@@ -91,8 +80,10 @@
 		"	.set	reorder			\n"\
 		".previous")
 
-#define	MD_INIT_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.init, init_fallthru)
-#define	MD_FINI_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.fini, fini_fallthru)
+#define	MD_INIT_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.init, _init)
+#define	MD_FINI_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.fini, _fini)
 
 #define	MD_INIT_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.init)
 #define	MD_FINI_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.fini)
+
+#define	MD_DO_NOT_NEED_FALLTHRU