This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH RFA]: never include crt0 for mips embedded targets.


The patch below causes crt0 to never be automatically included for
embedded MIPS targets which use mips/elf.h or mips/elf64.h.

libgloss for mips has the problem that some linker scripts specify
STARTUP files, and others do not (relying on the compiler to include
crt0).  Unfortunately, you can't use a linker script wihch specifies
STARTUP w/ a compiler target that includes crt0.o w/o explicitly
specifying -mno-crt0, an inconsistency that's ... fairly annoying, at
least to me.

This patch causes those headers to avoid including crt0.o in
STARTFILE_SPEC, allowing STARTUP to be used safely and consistently by
linker scripts.

I examined all targets whose configurations include those headers,
and, in a nutshell, it appears to me that none except the *-elf
configurations are affected.  The targets i examined are:

mips-wrs-vxworks, mips64orion-*-rtems*, mips*-*-rtems*

	includes mips/elf.h or mips/elf64.h from config.gcc, and a
	later file included by config.gcc undef's STARTFILE_SPEC.

mips-*-elf*, mipsel-*-elf*, mips64-*-elf*, mips64el-*-elf*,
mips64orion-*-elf*, mips64orionel-*-elf*, mipstx39-*-elf*,
mipstx39el-*-elf*, 

	affected.

mipsisa32-*-elf*, mipsisa32el-*-elf*, mipsisa64-*-elf*,
mipsisa64el-*-elf*

	this change keeps these configurations effectively the same.

mips*-*-netbsd*

	includes mips/elf.h from mips/netbsd.h, but later includes
	netbsd-elf.h which undefs/redefines STARTFILE_SPEC.

I didn't remove the -mno-crt0 option, in case somebody was planning to
reuse it or in case people are used to specifying it on the command
line... but with this patch it now has no effect.

I'm also about to submit a patch to newlib which adds STARTUP to all
of the MIPS linker scripts, to match this change.



chris
===================================================================
2002-07-23  Chris Demetriou  <cgd@broadcom.com>

	* config/mips/elf.h (STARTFILE_SPEC): Never include crt0.o.
	* config/mips/elf64.h (STARTFILE_SPEC): Likewise.
	* config/mips/isa3264.h (STARTFILE_SPEC): Do not redefine.

Index: config/mips/elf.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/mips/elf.h,v
retrieving revision 1.37
diff -u -p -r1.37 elf.h
--- config/mips/elf.h	12 Jun 2002 18:07:32 -0000	1.37
+++ config/mips/elf.h	24 Jul 2002 01:36:29 -0000
@@ -263,8 +263,11 @@ void FN ()                              
 #undef LIB_SPEC
 #define LIB_SPEC ""
 
+/* Don't link with crt0 files, let the linker start files specify
+   the appropriate crt0 file.  This is overridden by non-embedded
+   targets which wish to provide a crt0.o by default.  */
 #undef  STARTFILE_SPEC
-#define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
+#define STARTFILE_SPEC "crti%O%s crtbegin%O%s"
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
Index: config/mips/elf64.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/mips/elf64.h,v
retrieving revision 1.43
diff -u -p -r1.43 elf64.h
--- config/mips/elf64.h	11 Jun 2002 07:26:37 -0000	1.43
+++ config/mips/elf64.h	24 Jul 2002 01:36:29 -0000
@@ -237,8 +237,11 @@ void FN ()                              
 #undef LIB_SPEC
 #define LIB_SPEC ""
 
+/* Don't link with crt0 files, let the linker start files specify
+   the appropriate crt0 file.  This is overridden by non-embedded
+   targets which wish to provide a crt0.o by default.  */
 #undef  STARTFILE_SPEC
-#define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0:crt0%O%s}"
+#define STARTFILE_SPEC "crti%O%s crtbegin%O%s"
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
Index: config/mips/isa3264.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/mips/isa3264.h,v
retrieving revision 1.5
diff -u -p -r1.5 isa3264.h
--- config/mips/isa3264.h	17 Jan 2002 07:53:55 -0000	1.5
+++ config/mips/isa3264.h	24 Jul 2002 01:36:29 -0000
@@ -36,10 +36,3 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 #include "mips/elf.h"
-
-#if MIPS_ABI_DEFAULT == ABI_MEABI
-/* For MEABI, don't link with crt0 files, let the linker start files specify
-   the appropriate crt0 file.  */
-#undef  STARTFILE_SPEC
-#define STARTFILE_SPEC "crti%O%s crtbegin%O%s %{!mno-crt0: }"
-#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]