Update default powerpc-eabi configuration

Daniel Jacobowitz drow@false.org
Mon Mar 19 20:06:00 GMT 2007


I'd like comments on this patch.  powerpc-eabi is different from a
number of other foo-elf and foo-eabi targets in that it does not link
by default.  I understand the reason for this, and I'm not trying to
change it, but I'd like to move it a small way towards other targets.

When you supply an option, such as -msim, GCC suddenly knows about
a couple of different things:

#define LIB_SIM_SPEC "--start-group -lsim -lc --end-group"

#define STARTFILE_SIM_SPEC "ecrti.o%s sim-crt0.o%s crtbegin.o%s"

#define ENDFILE_SIM_SPEC "crtend.o%s ecrtn.o%s"

#define LINK_OS_SIM_SPEC "-m elf32ppcsim"

libsim.a, sim-crt0.o, and elf32ppcsim are all simulator-specific.
They're not default because they aren't appropriate for non-sim
targets.

Last week, I tried to add a new board configuration without hardcoding
any of it in GCC.  The additional linker script complexity required
was too high to get it to work reliably - in particular getting
startfiles at the start of things and endfiles at the end of things.
While possible, it was much easier to modify GCC.  So this is how I
did it, without moving any of the board details into GCC.  It knows
about ecrti.o, crtbegin.o, crtend.o, ecrtn.o, and libc.a - but nothing
else.

If you try to link without specifying more you'll get missing symbols
from the board support library (like "read"), and a linker warning
about missing _start (which should probably be an error, IMO, but
anyway...).  Nothing will be linked into your program which is
specific to a particular EABI environment.

The linker script has to be specified on the command line.  It can
then use STARTUP to find foo-crt0.o, and GROUP(-lfoo -lc -lgcc) to
load the board-specific support files from libgloss.  The linker
script is easy to write and does not need separate matches for ecrtn.o
and crtend.o in a dozen sections.

What do you think?  OK to commit?

-- 
Daniel Jacobowitz
CodeSourcery

2007-03-19  Daniel Jacobowitz  <dan@codesourcery.com>

	* config/rs6000/sysv4.h (STARTFILE_DEFAULT_SPEC): Include
	ecrti.o and crtbegin.o.
	(LIB_DEFAULT_SPEC): Include -lc.
	(ENDFILE_DEFAULT_SPEC): Include crtend.o and ecrtn.o.

Index: gcc/config/rs6000/sysv4.h
===================================================================
--- gcc/config/rs6000/sysv4.h	(revision 166062)
+++ gcc/config/rs6000/sysv4.h	(working copy)
@@ -902,7 +902,7 @@ extern int fixuplabelno;
   mcall-openbsd: %(startfile_openbsd)     ; \
                : %(startfile_default)     }"
 
-#define	STARTFILE_DEFAULT_SPEC ""
+#define	STARTFILE_DEFAULT_SPEC "ecrti.o%s crtbegin.o%s"
 
 /* Override svr4.h definition.  */
 #undef	LIB_SPEC
@@ -919,7 +919,7 @@ extern int fixuplabelno;
   mcall-openbsd: %(lib_openbsd)     ; \
                : %(lib_default)     }"
 
-#define LIB_DEFAULT_SPEC ""
+#define LIB_DEFAULT_SPEC "-lc"
 
 /* Override svr4.h definition.  */
 #undef	ENDFILE_SPEC
@@ -938,7 +938,7 @@ extern int fixuplabelno;
 
 #define CRTSAVRES_DEFAULT_SPEC "crtsavres.o%s"
 
-#define	ENDFILE_DEFAULT_SPEC ""
+#define	ENDFILE_DEFAULT_SPEC "crtend.o%s ecrtn.o%s"
 
 /* Motorola ADS support.  */
 #define LIB_ADS_SPEC "--start-group -lads -lc --end-group"



More information about the Gcc-patches mailing list