[PATCH] use #line in generated ld/e*.c source files

Roland McGrath roland@redhat.com
Tue Jul 17 04:37:00 GMT 2007


This patch makes the generated C files use #line to refer to the .em files
that are the actual sources.  This makes life much better for debugging.


Thanks,
Roland


2007-07-16  Roland McGrath  <roland@redhat.com>

	* genscripts.sh (source_em, fragment): New sh functions.
	Truncate e${EMULATION_NAME}.c file before .em script fills it.
	Use source_em in place of . for the .em script.
	* emultempl/generic.em: Use fragment and source_em functions.
	* emultempl/aix.em: Likewise.
	* emultempl/alphaelf.em: Likewise.
	* emultempl/armcoff.em: Likewise.
	* emultempl/armelf.em: Likewise.
	* emultempl/avrelf.em: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/cr16elf.em: Likewise.
	* emultempl/crxelf.em: Likewise.
	* emultempl/elf-generic.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/genelf.em: Likewise.
	* emultempl/gld960.em: Likewise.
	* emultempl/gld960c.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/ia64elf.em: Likewise.
	* emultempl/irix.em: Likewise.
	* emultempl/linux.em: Likewise.
	* emultempl/lnk960.em: Likewise.
	* emultempl/m68hc1xelf.em: Likewise.
	* emultempl/m68kcoff.em: Likewise.
	* emultempl/m68kelf.em: Likewise.
	* emultempl/mipsecoff.em: Likewise.
	* emultempl/mipself.em: Likewise.
	* emultempl/mmix-elfnmmo.em: Likewise.
	* emultempl/mmixelf.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/needrelax.em: Likewise.
	* emultempl/netbsd.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/scoreelf.em: Likewise.
	* emultempl/sh64elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/sunos.em: Likewise.
	* emultempl/ticoff.em: Likewise.
	* emultempl/vanilla.em: Likewise.
	* emultempl/vxworks.em: Likewise.
	* emultempl/xtensaelf.em: Likewise.
	* emultempl/z80.em: Likewise.

Index: ld/genscripts.sh
===================================================================
RCS file: /cvs/src/src/ld/genscripts.sh,v
retrieving revision 1.23
diff -B -b -p -u -r1.23 genscripts.sh
--- ld/genscripts.sh	6 Jul 2007 14:09:41 -0000	1.23
+++ ld/genscripts.sh	17 Jul 2007 01:10:41 -0000
@@ -393,5 +393,33 @@ case " $EMULATION_LIBPATH " in
     *" ${EMULATION_NAME} "*) COMPILE_IN=true;;
 esac
 
+if test -n "${BASH+set}"; then
+  source_em()
+  {
+    local current_script="$em_script"
+    em_script=$1
+    . $em_script
+    em_script=$current_script
+  }
+  fragment()
+  {
+    local lineno=$[${BASH_LINENO[0]} + 1]
+    echo >> e${EMULATION_NAME}.c "#line $lineno \"$em_script\""
+    cat >> e${EMULATION_NAME}.c
+  }
+else
+  source_em()
+  {
+    . $1
+  }
+  fragment()
+  {
+    cat >> e${EMULATION_NAME}.c
+  }
+fi
+
 # Generate e${EMULATION_NAME}.c.
-. ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
+# Start with an empty file, then the sourced .em script
+# can use the "fragment" function to append.
+> e${EMULATION_NAME}.c
+source_em ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em
Index: ld/emultempl/aix.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/aix.em,v
retrieving revision 1.45
diff -B -b -p -u -r1.45 aix.em
--- ld/emultempl/aix.em	6 Jul 2007 14:09:42 -0000	1.45
+++ ld/emultempl/aix.em	17 Jul 2007 01:10:41 -0000
@@ -5,7 +5,7 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* AIX emulation code for ${EMULATION_NAME}
@@ -1271,7 +1271,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f ${srcdir}/emultempl/ostring.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -1292,7 +1292,7 @@ echo '; }'					       >> e${EMULATION_NA
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -1311,7 +1311,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_create_output_section_statements (void)
Index: ld/emultempl/alphaelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/alphaelf.em,v
retrieving revision 1.8
diff -B -b -p -u -r1.8 alphaelf.em
--- ld/emultempl/alphaelf.em	6 Jul 2007 14:09:42 -0000	1.8
+++ ld/emultempl/alphaelf.em	17 Jul 2007 01:10:41 -0000
@@ -22,7 +22,7 @@
 # This file is sourced from elf32.em, and defines extra alpha
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "elf/internal.h"
 #include "elf/alpha.h"
Index: ld/emultempl/armcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armcoff.em,v
retrieving revision 1.26
diff -B -b -p -u -r1.26 armcoff.em
--- ld/emultempl/armcoff.em	6 Jul 2007 14:09:42 -0000	1.26
+++ ld/emultempl/armcoff.em	17 Jul 2007 01:10:41 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* emulate the original gld for the given ${EMULATION_NAME}
@@ -210,7 +210,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -231,7 +231,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -250,7 +250,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.56
diff -B -b -p -u -r1.56 armelf.em
--- ld/emultempl/armelf.em	6 Jul 2007 14:09:42 -0000	1.56
+++ ld/emultempl/armelf.em	17 Jul 2007 01:10:41 -0000
@@ -25,7 +25,7 @@
 # specific routines.
 #
 test -z "$TARGET2_TYPE" && TARGET2_TYPE="rel"
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "elf/arm.h"
 
Index: ld/emultempl/avrelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/avrelf.em,v
retrieving revision 1.3
diff -B -b -p -u -r1.3 avrelf.em
--- ld/emultempl/avrelf.em	6 Jul 2007 14:09:42 -0000	1.3
+++ ld/emultempl/avrelf.em	17 Jul 2007 01:10:41 -0000
@@ -25,7 +25,7 @@
 # of devices where one needs to address the issue that it is not possible
 # to reach the whole program memory by using 16 bit pointers.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "elf32-avr.h"
 #include "ldctor.h"
Index: ld/emultempl/beos.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/beos.em,v
retrieving revision 1.37
diff -B -b -p -u -r1.37 beos.em
--- ld/emultempl/beos.em	6 Jul 2007 14:09:42 -0000	1.37
+++ ld/emultempl/beos.em	17 Jul 2007 01:10:41 -0000
@@ -5,7 +5,7 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is part of GLD, the Gnu Linker.
    Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    2005, 2006, 2007 Free Software Foundation, Inc.
@@ -737,7 +737,7 @@ EOF
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -755,7 +755,7 @@ echo '  ; else return'                  
 sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
 echo '; }'                                             >> e${EMULATION_NAME}.c
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
Index: ld/emultempl/cr16elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/cr16elf.em,v
retrieving revision 1.2
diff -B -b -p -u -r1.2 cr16elf.em
--- ld/emultempl/cr16elf.em	6 Jul 2007 14:09:42 -0000	1.2
+++ ld/emultempl/cr16elf.em	17 Jul 2007 01:10:41 -0000
@@ -23,7 +23,7 @@
 # This file is sourced from elf32.em, and defines extra cr16-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "ldctor.h"
 
Index: ld/emultempl/crxelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/crxelf.em,v
retrieving revision 1.4
diff -B -b -p -u -r1.4 crxelf.em
--- ld/emultempl/crxelf.em	6 Jul 2007 14:09:42 -0000	1.4
+++ ld/emultempl/crxelf.em	17 Jul 2007 01:10:41 -0000
@@ -23,7 +23,7 @@
 # This file is sourced from elf32.em, and defines extra crx-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "ldctor.h"
 
Index: ld/emultempl/elf-generic.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf-generic.em,v
retrieving revision 1.5
diff -B -b -p -u -r1.5 elf-generic.em
--- ld/emultempl/elf-generic.em	6 Jul 2007 14:09:42 -0000	1.5
+++ ld/emultempl/elf-generic.em	17 Jul 2007 01:10:41 -0000
@@ -22,7 +22,7 @@
 # This file is sourced from elf32.em and from ELF targets that use
 # generic.em.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_map_segments (bfd_boolean need_layout)
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.181
diff -B -b -p -u -r1.181 elf32.em
--- ld/emultempl/elf32.em	13 Jul 2007 10:44:26 -0000	1.181
+++ ld/emultempl/elf32.em	17 Jul 2007 01:10:41 -0000
@@ -8,7 +8,7 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
@@ -70,7 +70,7 @@ EOF
 if [ "x${USE_LIBPATH}" = xyes ] ; then
   case ${target} in
     *-*-linux-* | *-*-k*bsd*-*)
-  cat >>e${EMULATION_NAME}.c <<EOF
+  fragment <<EOF
 #ifdef HAVE_GLOB
 #include <glob.h>
 #endif
@@ -81,9 +81,9 @@ fi
 
 # Import any needed special functions and/or overrides.
 #
-. ${srcdir}/emultempl/elf-generic.em
+source_em ${srcdir}/emultempl/elf-generic.em
 if test -n "$EXTRA_EM_FILE" ; then
-. ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
+  source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
 fi
 
 # Functions in this file can be overridden by setting the LDEMUL_* shell
@@ -93,7 +93,7 @@ fi
 # as presumably it is called from the overriding function.
 #
 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_before_parse (void)
@@ -107,7 +107,7 @@ EOF
 fi
 
 if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* Handle as_needed DT_NEEDED.  */
 
 static bfd_boolean
@@ -144,7 +144,7 @@ gld${EMULATION_NAME}_load_symbols (lang_
 EOF
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* These variables are required to pass information back and forth
    between after_open and check_needed and stat_needed and vercheck.  */
@@ -363,7 +363,7 @@ gld${EMULATION_NAME}_try_needed (struct 
 EOF
 case ${target} in
   *-*-linux-* | *-*-k*bsd*-*)
-    cat >>e${EMULATION_NAME}.c <<EOF
+    fragment <<EOF
 	  {
 	    struct bfd_link_needed_list *l;
 
@@ -380,7 +380,7 @@ case ${target} in
 EOF
     ;;
 esac
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	}
     }
 
@@ -493,7 +493,7 @@ gld${EMULATION_NAME}_search_needed (cons
 
 EOF
 if [ "x${USE_LIBPATH}" = xyes ] ; then
-  cat >>e${EMULATION_NAME}.c <<EOF
+  fragment <<EOF
 
 /* Add the sysroot to every entry in a path separated by
    config.rpath_separator.  */
@@ -536,7 +536,7 @@ gld${EMULATION_NAME}_add_sysroot (const 
 EOF
   case ${target} in
     *-*-freebsd* | *-*-dragonfly*)
-      cat >>e${EMULATION_NAME}.c <<EOF
+      fragment <<EOF
 /* Read the system search path the FreeBSD way rather than the Linux way.  */
 #ifdef HAVE_ELF_HINTS_H
 #include <elf-hints.h>
@@ -598,7 +598,7 @@ EOF
     ;;
 
     *-*-linux-* | *-*-k*bsd*-*)
-      cat >>e${EMULATION_NAME}.c <<EOF
+      fragment <<EOF
 /* For a native linker, check the file /etc/ld.so.conf for directories
    in which we may find shared libraries.  /etc/ld.so.conf is really
    only meaningful on Linux.  */
@@ -808,7 +808,7 @@ EOF
     ;;
   esac
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* See if an input file matches a DT_NEEDED entry by name.  */
 
@@ -860,7 +860,7 @@ gld${EMULATION_NAME}_check_needed (lang_
 EOF
 
 if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static bfd_size_type
 gld${EMULATION_NAME}_id_note_section_size (bfd *abfd,
@@ -1187,31 +1187,31 @@ gld${EMULATION_NAME}_after_open (void)
 	  search_dirs_type *search;
 EOF
 if [ "x${NATIVE}" = xyes ] ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	  const char *lib_path;
 EOF
 fi
 if [ "x${USE_LIBPATH}" = xyes ] ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	  struct bfd_link_needed_list *rp;
 	  int found;
 EOF
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 	  if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
 						  &n, force))
 	    break;
 EOF
 if [ "x${USE_LIBPATH}" = xyes ] ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	  if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
 						  &n, force))
 	    break;
 EOF
 fi
 if [ "x${NATIVE}" = xyes ] ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	  if (command_line.rpath_link == NULL
 	      && command_line.rpath == NULL)
 	    {
@@ -1226,7 +1226,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
 fi
 if [ "x${USE_LIBPATH}" = xyes ] ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	  found = 0;
 	  rp = bfd_elf_get_runpath_list (output_bfd, &link_info);
 	  for (; !found && rp != NULL; rp = rp->next)
@@ -1246,7 +1246,7 @@ fi
 if [ "x${USE_LIBPATH}" = xyes ] ; then
   case ${target} in
     *-*-freebsd* | *-*-dragonfly*)
-      cat >>e${EMULATION_NAME}.c <<EOF
+      fragment <<EOF
 	  if (gld${EMULATION_NAME}_check_ld_elf_hints (l->name, force))
 	    break;
 EOF
@@ -1255,7 +1255,7 @@ EOF
 
     *-*-linux-* | *-*-k*bsd*-*)
     # Linux
-      cat >>e${EMULATION_NAME}.c <<EOF
+      fragment <<EOF
 	  if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force))
 	    break;
 
@@ -1263,7 +1263,7 @@ EOF
     ;;
   esac
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	  len = strlen (l->name);
 	  for (search = search_head; search != NULL; search = search->next)
 	    {
@@ -1281,7 +1281,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 	  if (search != NULL)
 	    break;
 EOF
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 	}
 
       if (force < 2)
@@ -1295,7 +1295,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* Look through an expression for an assignment statement.  */
 
@@ -1376,7 +1376,7 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != 
   else
     ELF_INTERPRETER_SET_DEFAULT=
   fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* This is called after the sections have been attached to output
    sections, but before any sizes or addresses have been set.  */
@@ -1477,7 +1477,7 @@ EOF
 fi
 
 if test x"$LDEMUL_OPEN_DYNAMIC_ARCHIVE" != xgld"$EMULATION_NAME"_open_dynamic_archive; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* Try to open a dynamic archive.  This is where we know that ELF
    dynamic libraries have an extension of .so (or .sl on oddball systems
@@ -1556,7 +1556,7 @@ EOF
 fi
 
 if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* A variant of lang_output_section_find used by place_orphan.  */
 
@@ -1806,7 +1806,7 @@ EOF
 fi
 
 if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_finish (void)
@@ -1820,7 +1820,7 @@ EOF
 fi
 
 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static char *
 gld${EMULATION_NAME}_get_script (int *isfile)
@@ -1833,7 +1833,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -1887,7 +1887,7 @@ echo '; }'						>> e${EMULATION_NAME}.c
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -1900,14 +1900,14 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
 if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then :
 else
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else if (!config.magic_demand_paged)
     return "ldscripts/${EMULATION_NAME}.xn";
 EOF
 fi
 if test -n "$GENERATE_PIE_SCRIPT" ; then
 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else if (link_info.pie && link_info.combreloc
 	   && link_info.relro && (link_info.flags & DT_BIND_NOW))
     return "ldscripts/${EMULATION_NAME}.xdw";
@@ -1915,14 +1915,14 @@ cat >>e${EMULATION_NAME}.c <<EOF
     return "ldscripts/${EMULATION_NAME}.xdc";
 EOF
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else if (link_info.pie)
     return "ldscripts/${EMULATION_NAME}.xd";
 EOF
 fi
 if test -n "$GENERATE_SHLIB_SCRIPT" ; then
 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else if (link_info.shared && link_info.combreloc
 	   && link_info.relro && (link_info.flags & DT_BIND_NOW))
     return "ldscripts/${EMULATION_NAME}.xsw";
@@ -1930,13 +1930,13 @@ cat >>e${EMULATION_NAME}.c <<EOF
     return "ldscripts/${EMULATION_NAME}.xsc";
 EOF
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else if (link_info.shared)
     return "ldscripts/${EMULATION_NAME}.xs";
 EOF
 fi
 if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else if (link_info.combreloc && link_info.relro
 	   && (link_info.flags & DT_BIND_NOW))
     return "ldscripts/${EMULATION_NAME}.xw";
@@ -1944,7 +1944,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
     return "ldscripts/${EMULATION_NAME}.xc";
 EOF
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   else
     return "ldscripts/${EMULATION_NAME}.x";
 }
@@ -1956,12 +1956,12 @@ fi
 if test -n "$PARSE_AND_LIST_ARGS_CASES" -o x"$GENERATE_SHLIB_SCRIPT" = xyes; then
 
 if test -n "$PARSE_AND_LIST_PROLOGUE" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
  $PARSE_AND_LIST_PROLOGUE
 EOF
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #define OPTION_DISABLE_NEW_DTAGS	(400)
 #define OPTION_ENABLE_NEW_DTAGS		(OPTION_DISABLE_NEW_DTAGS + 1)
@@ -1982,7 +1982,7 @@ gld${EMULATION_NAME}_add_options
 EOF
 
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
     {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
     {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
     {"eh-frame-hdr", no_argument, NULL, OPTION_EH_FRAME_HDR},
@@ -1993,12 +1993,12 @@ EOF
 fi
 
 if test -n "$PARSE_AND_LIST_LONGOPTS" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
     $PARSE_AND_LIST_LONGOPTS
 EOF
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
     {NULL, no_argument, NULL, 0}
   };
 
@@ -2034,7 +2034,7 @@ gld${EMULATION_NAME}_handle_option (int 
 EOF
 
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
     case OPTION_DISABLE_NEW_DTAGS:
       link_info.new_dtags = FALSE;
       break;
@@ -2127,7 +2127,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
 
   if test -n "$COMMONPAGESIZE"; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
       else if (strcmp (optarg, "relro") == 0)
 	link_info.relro = TRUE;
       else if (strcmp (optarg, "norelro") == 0)
@@ -2135,7 +2135,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
   fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
       else if (CONST_STRNEQ (optarg, "max-page-size="))
 	{
 	  char *end;
@@ -2165,12 +2165,12 @@ EOF
 fi
 
 if test -n "$PARSE_AND_LIST_ARGS_CASES" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
  $PARSE_AND_LIST_ARGS_CASES
 EOF
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
     }
 
   return TRUE;
@@ -2179,7 +2179,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
 
 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_list_options (FILE * file)
@@ -2188,7 +2188,7 @@ gld${EMULATION_NAME}_list_options (FILE 
 EOF
 
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   fprintf (file, _("  -Bgroup\t\tSelects group name lookup rules for DSO\n"));
   fprintf (file, _("  --disable-new-dtags\tDisable new dynamic tags\n"));
   fprintf (file, _("  --enable-new-dtags\tEnable new dynamic tags\n"));
@@ -2212,23 +2212,23 @@ cat >>e${EMULATION_NAME}.c <<EOF
 EOF
 
   if test -n "$COMMONPAGESIZE"; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   fprintf (file, _("  -z norelro\t\tDon't create RELRO program header\n"));
 EOF
   fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   fprintf (file, _("  -z now\t\tMark object non-lazy runtime binding\n"));
   fprintf (file, _("  -z origin\t\tMark object requiring immediate \$ORIGIN processing\n\t\t\t  at runtime\n"));
 EOF
 
   if test -n "$COMMONPAGESIZE"; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   fprintf (file, _("  -z relro\t\tCreate RELRO program header\n"));
 EOF
   fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   fprintf (file, _("  -z max-page-size=SIZE\tSet maximum page size to SIZE\n"));
   fprintf (file, _("  -z common-page-size=SIZE\n\t\t\tSet common page size to SIZE\n"));
   fprintf (file, _("  -z KEYWORD\t\tIgnored for Solaris compatibility\n"));
@@ -2236,34 +2236,34 @@ EOF
 fi
 
 if test -n "$PARSE_AND_LIST_OPTIONS" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
  $PARSE_AND_LIST_OPTIONS
 EOF
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 }
 EOF
 
 if test -n "$PARSE_AND_LIST_EPILOGUE" ; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
  $PARSE_AND_LIST_EPILOGUE
 EOF
 fi
 fi
 else
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 #define gld${EMULATION_NAME}_add_options NULL
 #define gld${EMULATION_NAME}_handle_option NULL
 EOF
 if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 #define gld${EMULATION_NAME}_list_options NULL
 EOF
 fi
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
Index: ld/emultempl/genelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/genelf.em,v
retrieving revision 1.2
diff -B -b -p -u -r1.2 genelf.em
--- ld/emultempl/genelf.em	6 Jul 2007 14:09:42 -0000	1.2
+++ ld/emultempl/genelf.em	17 Jul 2007 01:10:41 -0000
@@ -21,12 +21,12 @@
 
 # This file is sourced from generic.em
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 #include "elf-bfd.h"
 
 EOF
-. ${srcdir}/emultempl/elf-generic.em
-cat >>e${EMULATION_NAME}.c <<EOF
+source_em ${srcdir}/emultempl/elf-generic.em
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_finish (void)
Index: ld/emultempl/generic.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/generic.em,v
retrieving revision 1.21
diff -B -b -p -u -r1.21 generic.em
--- ld/emultempl/generic.em	6 Jul 2007 14:09:42 -0000	1.21
+++ ld/emultempl/generic.em	17 Jul 2007 01:10:41 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* emulate the original gld for the given ${EMULATION_NAME}
@@ -45,11 +45,11 @@ EOF
 # Import any needed special functions and/or overrides.
 #
 if test -n "$EXTRA_EM_FILE" ; then
-. ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
+  source_em ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
 fi
 
 if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_before_parse (void)
@@ -63,7 +63,7 @@ EOF
 fi
 
 if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static char *
 gld${EMULATION_NAME}_get_script (int *isfile)
@@ -76,7 +76,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -97,7 +97,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -116,7 +116,7 @@ EOF
 fi
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
Index: ld/emultempl/gld960.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/gld960.em,v
retrieving revision 1.21
diff -B -b -p -u -r1.21 gld960.em
--- ld/emultempl/gld960.em	6 Jul 2007 14:09:42 -0000	1.21
+++ ld/emultempl/gld960.em	17 Jul 2007 01:10:41 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* Copyright 1991, 1992, 1994, 1999, 2000, 2001, 2002, 2003, 2005, 2007
    Free Software Foundation, Inc.
 
@@ -80,7 +80,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -101,7 +101,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -120,7 +120,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_gld960_emulation =
 {
Index: ld/emultempl/gld960c.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/gld960c.em,v
retrieving revision 1.23
diff -B -b -p -u -r1.23 gld960c.em
--- ld/emultempl/gld960c.em	6 Jul 2007 14:09:42 -0000	1.23
+++ ld/emultempl/gld960c.em	17 Jul 2007 01:10:41 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003, 2004,
    2005, 2007 Free Software Foundation, Inc.
 
@@ -94,7 +94,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -115,7 +115,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -134,7 +134,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_gld960coff_emulation =
 {
Index: ld/emultempl/hppaelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/hppaelf.em,v
retrieving revision 1.47
diff -B -b -p -u -r1.47 hppaelf.em
--- ld/emultempl/hppaelf.em	6 Jul 2007 14:09:42 -0000	1.47
+++ ld/emultempl/hppaelf.em	17 Jul 2007 01:10:41 -0000
@@ -23,7 +23,7 @@
 # This file is sourced from elf32.em, and defines extra hppa-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "ldctor.h"
 #include "elf32-hppa.h"
Index: ld/emultempl/ia64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ia64elf.em,v
retrieving revision 1.6
diff -B -b -p -u -r1.6 ia64elf.em
--- ld/emultempl/ia64elf.em	6 Jul 2007 14:09:42 -0000	1.6
+++ ld/emultempl/ia64elf.em	17 Jul 2007 01:10:41 -0000
@@ -25,7 +25,7 @@
 # Define some shell vars to insert bits of code into the standard elf
 # parse_args and list_options functions.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* None zero if generating binary for Intel Itanium processor.  */
 static int itanium = 0;
@@ -60,4 +60,4 @@ PARSE_AND_LIST_ARGS_CASES='
 '
 
 LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse
-. ${srcdir}/emultempl/needrelax.em
+source_em ${srcdir}/emultempl/needrelax.em
Index: ld/emultempl/irix.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/irix.em,v
retrieving revision 1.5
diff -B -b -p -u -r1.5 irix.em
--- ld/emultempl/irix.em	6 Jul 2007 14:09:42 -0000	1.5
+++ ld/emultempl/irix.em	17 Jul 2007 01:10:41 -0000
@@ -19,7 +19,7 @@
 # MA 02110-1301, USA.
 #
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "ld.h"
 #include "ldmain.h"
@@ -40,4 +40,4 @@ irix_after_open (void)
 EOF
 
 LDEMUL_AFTER_OPEN=irix_after_open
-. "${srcdir}/emultempl/mipself.em"
+source_em "${srcdir}/emultempl/mipself.em"
Index: ld/emultempl/linux.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/linux.em,v
retrieving revision 1.22
diff -B -b -p -u -r1.22 linux.em
--- ld/emultempl/linux.em	6 Jul 2007 14:09:42 -0000	1.22
+++ ld/emultempl/linux.em	17 Jul 2007 01:10:41 -0000
@@ -5,7 +5,7 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* Linux a.out emulation code for ${EMULATION_NAME}
@@ -137,7 +137,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -158,7 +158,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -177,7 +177,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
Index: ld/emultempl/lnk960.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/lnk960.em,v
retrieving revision 1.22
diff -B -b -p -u -r1.22 lnk960.em
--- ld/emultempl/lnk960.em	6 Jul 2007 14:09:42 -0000	1.22
+++ ld/emultempl/lnk960.em	17 Jul 2007 01:10:41 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* intel coff loader emulation specific stuff
    Copyright 1991, 1992, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003,
    2005, 2007 Free Software Foundation, Inc.
@@ -217,7 +217,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -238,7 +238,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -257,7 +257,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_lnk960_emulation =
 {
Index: ld/emultempl/m68hc1xelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/m68hc1xelf.em,v
retrieving revision 1.8
diff -B -b -p -u -r1.8 m68hc1xelf.em
--- ld/emultempl/m68hc1xelf.em	6 Jul 2007 14:09:42 -0000	1.8
+++ ld/emultempl/m68hc1xelf.em	17 Jul 2007 01:10:42 -0000
@@ -40,7 +40,7 @@
 #
 # Copied from hppaelf and adapted for M68HC11/M68HC12 specific needs.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "ldctor.h"
 #include "elf32-m68hc1x.h"
Index: ld/emultempl/m68kcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/m68kcoff.em,v
retrieving revision 1.18
diff -B -b -p -u -r1.18 m68kcoff.em
--- ld/emultempl/m68kcoff.em	6 Jul 2007 14:09:42 -0000	1.18
+++ ld/emultempl/m68kcoff.em	17 Jul 2007 01:10:42 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* Handle embedded relocs for m68k.
@@ -171,7 +171,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -192,7 +192,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -211,7 +211,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
Index: ld/emultempl/m68kelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/m68kelf.em,v
retrieving revision 1.9
diff -B -b -p -u -r1.9 m68kelf.em
--- ld/emultempl/m68kelf.em	6 Jul 2007 14:09:42 -0000	1.9
+++ ld/emultempl/m68kelf.em	17 Jul 2007 01:10:42 -0000
@@ -31,7 +31,7 @@ case ${target} in
     ;;
 esac
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #ifdef SUPPORT_EMBEDDED_RELOCS
 static void check_sections (bfd *, asection *, void *);
Index: ld/emultempl/mipsecoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mipsecoff.em,v
retrieving revision 1.18
diff -B -b -p -u -r1.18 mipsecoff.em
--- ld/emultempl/mipsecoff.em	6 Jul 2007 14:09:42 -0000	1.18
+++ ld/emultempl/mipsecoff.em	17 Jul 2007 01:10:42 -0000
@@ -25,7 +25,7 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 static void
 gld${EMULATION_NAME}_before_parse (void)
 {
Index: ld/emultempl/mipself.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mipself.em,v
retrieving revision 1.8
diff -B -b -p -u -r1.8 mipself.em
--- ld/emultempl/mipself.em	6 Jul 2007 14:09:42 -0000	1.8
+++ ld/emultempl/mipself.em	17 Jul 2007 01:10:42 -0000
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 static void
 mips_after_parse (void)
 {
Index: ld/emultempl/mmix-elfnmmo.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mmix-elfnmmo.em,v
retrieving revision 1.13
diff -B -b -p -u -r1.13 mmix-elfnmmo.em
--- ld/emultempl/mmix-elfnmmo.em	6 Jul 2007 14:09:42 -0000	1.13
+++ ld/emultempl/mmix-elfnmmo.em	17 Jul 2007 01:10:42 -0000
@@ -22,7 +22,7 @@
 # This file is sourced from elf32.em and mmo.em, used to define
 # MMIX-specific things common to ELF and MMO.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 #include "elf/mmix.h"
 
 /* Set up handling of linker-allocated global registers.  */
Index: ld/emultempl/mmixelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mmixelf.em,v
retrieving revision 1.6
diff -B -b -p -u -r1.6 mmixelf.em
--- ld/emultempl/mmixelf.em	6 Jul 2007 14:09:42 -0000	1.6
+++ ld/emultempl/mmixelf.em	17 Jul 2007 01:10:42 -0000
@@ -22,9 +22,9 @@
 # This file is sourced from elf32.em and used to define MMIX and ELF
 # specific things.  First include what we have in common with mmo.
 
-. ${srcdir}/emultempl/mmix-elfnmmo.em
+source_em ${srcdir}/emultempl/mmix-elfnmmo.em
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 elfmmix_before_parse (void)
Index: ld/emultempl/mmo.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mmo.em,v
retrieving revision 1.20
diff -B -b -p -u -r1.20 mmo.em
--- ld/emultempl/mmo.em	6 Jul 2007 14:09:42 -0000	1.20
+++ ld/emultempl/mmo.em	17 Jul 2007 01:10:42 -0000
@@ -21,7 +21,7 @@
 
 # This file is sourced from generic.em.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* Need to have this macro defined before mmix-elfnmmo, which uses the
    name for the before_allocation function, defined in ldemul.c (for
    the mmo "emulation") or in elf32.em (for the elf64mmix
@@ -36,10 +36,10 @@ cat >>e${EMULATION_NAME}.c <<EOF
 #include "elf-bfd.h"
 EOF
 
-. ${srcdir}/emultempl/elf-generic.em
-. ${srcdir}/emultempl/mmix-elfnmmo.em
+source_em ${srcdir}/emultempl/elf-generic.em
+source_em ${srcdir}/emultempl/mmix-elfnmmo.em
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 /* Place an orphan section.  We use this to put random SEC_CODE or
    SEC_READONLY sections right after MMO_TEXT_SECTION_NAME.  Much borrowed
Index: ld/emultempl/needrelax.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/needrelax.em,v
retrieving revision 1.6
diff -B -b -p -u -r1.6 needrelax.em
--- ld/emultempl/needrelax.em	6 Jul 2007 14:09:42 -0000	1.6
+++ ld/emultempl/needrelax.em	17 Jul 2007 01:10:42 -0000
@@ -24,7 +24,7 @@
 
 LDEMUL_BEFORE_ALLOCATION=need_relax_${EMULATION_NAME}_before_allocation
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 need_relax_${EMULATION_NAME}_before_allocation (void)
Index: ld/emultempl/netbsd.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/netbsd.em,v
retrieving revision 1.5
diff -B -b -p -u -r1.5 netbsd.em
--- ld/emultempl/netbsd.em	6 Jul 2007 14:09:42 -0000	1.5
+++ ld/emultempl/netbsd.em	17 Jul 2007 01:10:42 -0000
@@ -21,7 +21,7 @@
 
 LDEMUL_BEFORE_PARSE=gldnetbsd_before_parse
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 static void
 gld${EMULATION_NAME}_before_parse (void);
 
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.125
diff -B -b -p -u -r1.125 pe.em
--- ld/emultempl/pe.em	6 Jul 2007 14:09:42 -0000	1.125
+++ ld/emultempl/pe.em	17 Jul 2007 01:10:42 -0000
@@ -8,7 +8,7 @@ else
 fi
 rm -f e${EMULATION_NAME}.c
 (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    2005, 2006, 2007 Free Software Foundation, Inc.
 
@@ -1877,7 +1877,7 @@ EOF
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -1895,7 +1895,7 @@ echo '  ; else return'					>> e${EMULATI
 sed $sc ldscripts/${EMULATION_NAME}.x			>> e${EMULATION_NAME}.c
 echo '; }'						>> e${EMULATION_NAME}.c
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
Index: ld/emultempl/pep.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pep.em,v
retrieving revision 1.3
diff -B -b -p -u -r1.3 pep.em
--- ld/emultempl/pep.em	6 Jul 2007 14:09:42 -0000	1.3
+++ ld/emultempl/pep.em	17 Jul 2007 01:10:42 -0000
@@ -8,7 +8,7 @@ else
 fi
 rm -f e${EMULATION_NAME}.c
 (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* Copyright 2006, 2007 Free Software Foundation, Inc.   
    Written by Kai Tietz, OneVision Software GmbH&CoKg.
 
@@ -1656,7 +1656,7 @@ EOF
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -1674,7 +1674,7 @@ echo '  ; else return'					>> e${EMULATI
 sed $sc ldscripts/${EMULATION_NAME}.x			>> e${EMULATION_NAME}.c
 echo '; }'						>> e${EMULATION_NAME}.c
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
Index: ld/emultempl/ppc32elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc32elf.em,v
retrieving revision 1.14
diff -B -b -p -u -r1.14 ppc32elf.em
--- ld/emultempl/ppc32elf.em	6 Jul 2007 14:09:42 -0000	1.14
+++ ld/emultempl/ppc32elf.em	17 Jul 2007 01:10:42 -0000
@@ -22,7 +22,7 @@
 # This file is sourced from elf32.em, and defines extra powerpc32-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "libbfd.h"
 #include "elf32-ppc.h"
@@ -126,7 +126,7 @@ ppc_before_allocation (void)
 EOF
 
 if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
-  cat >>e${EMULATION_NAME}.c <<EOF
+  fragment <<EOF
 /* Special handling for embedded SPU executables.  */
 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
 static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
Index: ld/emultempl/ppc64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc64elf.em,v
retrieving revision 1.54
diff -B -b -p -u -r1.54 ppc64elf.em
--- ld/emultempl/ppc64elf.em	6 Jul 2007 14:09:42 -0000	1.54
+++ ld/emultempl/ppc64elf.em	17 Jul 2007 01:10:42 -0000
@@ -22,7 +22,7 @@
 # This file is sourced from elf32.em, and defines extra powerpc64-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "ldctor.h"
 #include "libbfd.h"
@@ -466,7 +466,7 @@ ppc_lang_for_each_input_file (void (*fun
 EOF
 
 if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
-  cat >>e${EMULATION_NAME}.c <<EOF
+  fragment <<EOF
 /* Special handling for embedded SPU executables.  */
 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
 static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
Index: ld/emultempl/scoreelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/scoreelf.em,v
retrieving revision 1.2
diff -B -b -p -u -r1.2 scoreelf.em
--- ld/emultempl/scoreelf.em	6 Jul 2007 14:09:42 -0000	1.2
+++ ld/emultempl/scoreelf.em	17 Jul 2007 01:10:42 -0000
@@ -25,7 +25,7 @@
 # This file is sourced from elf32.em, and defines extra score-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static void
 gld${EMULATION_NAME}_before_parse ()
Index: ld/emultempl/sh64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/sh64elf.em,v
retrieving revision 1.11
diff -B -b -p -u -r1.11 sh64elf.em
--- ld/emultempl/sh64elf.em	6 Jul 2007 14:09:42 -0000	1.11
+++ ld/emultempl/sh64elf.em	17 Jul 2007 01:10:42 -0000
@@ -26,7 +26,7 @@
 LDEMUL_AFTER_ALLOCATION=sh64_elf_${EMULATION_NAME}_after_allocation
 LDEMUL_BEFORE_ALLOCATION=sh64_elf_${EMULATION_NAME}_before_allocation
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include "libiberty.h"
 #include "libbfd.h"
Index: ld/emultempl/spuelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/spuelf.em,v
retrieving revision 1.11
diff -B -b -p -u -r1.11 spuelf.em
--- ld/emultempl/spuelf.em	11 Jul 2007 22:58:09 -0000	1.11
+++ ld/emultempl/spuelf.em	17 Jul 2007 01:10:42 -0000
@@ -22,7 +22,7 @@
 # This file is sourced from elf32.em, and defines extra spu specific
 # features.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 #include "ldctor.h"
 #include "elf32-spu.h"
 
@@ -50,7 +50,7 @@ EOF
 
 ../binutils/bin2c < ${srcdir}/emultempl/spu_ovl.o >> e${EMULATION_NAME}.c
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 };
 
 static const struct _ovl_stream ovl_mgr_stream = {
@@ -247,7 +247,7 @@ gld${EMULATION_NAME}_finish (void)
 EOF
 
 if grep -q 'ld_elf.*ppc.*_emulation' ldemul-list.h; then
-  cat >>e${EMULATION_NAME}.c <<EOF
+  fragment <<EOF
 #include "filenames.h"
 #include <fcntl.h>
 #include <sys/wait.h>
Index: ld/emultempl/sunos.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/sunos.em,v
retrieving revision 1.28
diff -B -b -p -u -r1.28 sunos.em
--- ld/emultempl/sunos.em	6 Jul 2007 14:09:42 -0000	1.28
+++ ld/emultempl/sunos.em	17 Jul 2007 01:10:42 -0000
@@ -5,7 +5,7 @@ if [ -z "$MACHINE" ]; then
 else
   OUTPUT_ARCH=${ARCH}:${MACHINE}
 fi
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* SunOS emulation code for ${EMULATION_NAME}
@@ -101,7 +101,7 @@ EOF
 if [ "x${host}" = "x${target}" ] ; then
   case " ${EMULATION_LIBPATH} " in
   *" ${EMULATION_NAME} "*)
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
   const char *env;
 
   env = (const char *) getenv ("LD_LIBRARY_PATH");
@@ -128,7 +128,7 @@ EOF
   ;;
   esac
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 }
 
 /* Despite the name, we use this routine to search for dynamic
@@ -464,7 +464,7 @@ EOF
 if [ "x${host}" = "x${target}" ] ; then
   case " ${EMULATION_LIBPATH} " in
   *" ${EMULATION_NAME} "*)
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
       {
 	const char *lib_path;
 
@@ -476,7 +476,7 @@ EOF
   ;;
   esac
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
       if (command_line.rpath != NULL)
 	{
 	  for (search = search_head; search != NULL; search = search->next)
@@ -961,7 +961,7 @@ then
 # sed commands to quote an ld script as a C string.
 sc="-f stringify.sed"
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
 
@@ -982,7 +982,7 @@ echo '; }'                              
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -1001,7 +1001,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
Index: ld/emultempl/ticoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ticoff.em,v
retrieving revision 1.18
diff -B -b -p -u -r1.18 ticoff.em
--- ld/emultempl/ticoff.em	6 Jul 2007 14:09:42 -0000	1.18
+++ ld/emultempl/ticoff.em	17 Jul 2007 01:10:42 -0000
@@ -1,7 +1,7 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
 (echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* This file is part of GLD, the Gnu Linker.
    Copyright 1999, 2000, 2002, 2003, 2004, 2007
    Free Software Foundation, Inc.
@@ -116,7 +116,7 @@ s/$/\\n\\/
 1s/^/"/
 $s/$/n"/
 '
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 0;
   if (link_info.relocatable && config.build_constructors)
@@ -135,7 +135,7 @@ EOF
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -154,7 +154,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
   gld_${EMULATION_NAME}_before_parse,
Index: ld/emultempl/vanilla.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/vanilla.em,v
retrieving revision 1.15
diff -B -b -p -u -r1.15 vanilla.em
--- ld/emultempl/vanilla.em	6 Jul 2007 14:09:42 -0000	1.15
+++ ld/emultempl/vanilla.em	17 Jul 2007 01:10:42 -0000
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
-cat >e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* A vanilla emulation with no defaults
    Copyright 1991, 1992, 1994, 2000, 2001, 2002, 2003, 2007
    Free Software Foundation, Inc.
Index: ld/emultempl/vxworks.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/vxworks.em,v
retrieving revision 1.4
diff -B -b -p -u -r1.4 vxworks.em
--- ld/emultempl/vxworks.em	6 Jul 2007 14:09:42 -0000	1.4
+++ ld/emultempl/vxworks.em	17 Jul 2007 01:10:42 -0000
@@ -20,10 +20,10 @@
 #
 
 if test -n "$VXWORKS_BASE_EM_FILE" ; then
-. "${srcdir}/emultempl/${VXWORKS_BASE_EM_FILE}.em"
+  source_em "${srcdir}/emultempl/${VXWORKS_BASE_EM_FILE}.em"
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 static int force_dynamic;
 
@@ -93,7 +93,7 @@ for override in before_parse after_open;
   var="LDEMUL_`echo ${override} | tr a-z A-Z`"
   eval value=\$${var}
   if test "${value}" = "gld${EMULATION_NAME}_${override}"; then
-    cat >>e${EMULATION_NAME}.c <<EOF
+    fragment <<EOF
 #define ${value} vxworks_${override}
 EOF
   else
Index: ld/emultempl/xtensaelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/xtensaelf.em,v
retrieving revision 1.19
diff -B -b -p -u -r1.19 xtensaelf.em
--- ld/emultempl/xtensaelf.em	6 Jul 2007 14:09:42 -0000	1.19
+++ ld/emultempl/xtensaelf.em	17 Jul 2007 01:10:42 -0000
@@ -23,7 +23,7 @@
 # This file is sourced from elf32.em, and defines extra xtensa-elf
 # specific routines.
 #
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 #include <xtensa-config.h>
 #include "../bfd/elf-bfd.h"
Index: ld/emultempl/z80.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/z80.em,v
retrieving revision 1.2
diff -B -b -p -u -r1.2 z80.em
--- ld/emultempl/z80.em	6 Jul 2007 14:09:42 -0000	1.2
+++ ld/emultempl/z80.em	17 Jul 2007 01:10:42 -0000
@@ -23,7 +23,7 @@ LDEMUL_BEFORE_PARSE=gldz80_before_parse
 LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
 LDEMUL_AFTER_OPEN=gldz80_after_open
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 /* --- \begin{z80.em} */
 /* Codes for machine types, bitwise or gives the code to use for the
    output.  */



More information about the Binutils mailing list