2007-07-19 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@gnu.org>
Thu, 19 Jul 2007 19:56:10 +0000 (19:56 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 19 Jul 2007 19:56:10 +0000 (19:56 +0000)
* 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.

43 files changed:
ld/emultempl/aix.em
ld/emultempl/alphaelf.em
ld/emultempl/armcoff.em
ld/emultempl/armelf.em
ld/emultempl/avrelf.em
ld/emultempl/beos.em
ld/emultempl/cr16elf.em
ld/emultempl/crxelf.em
ld/emultempl/elf-generic.em
ld/emultempl/elf32.em
ld/emultempl/genelf.em
ld/emultempl/generic.em
ld/emultempl/gld960.em
ld/emultempl/gld960c.em
ld/emultempl/hppaelf.em
ld/emultempl/ia64elf.em
ld/emultempl/irix.em
ld/emultempl/linux.em
ld/emultempl/lnk960.em
ld/emultempl/m68hc1xelf.em
ld/emultempl/m68kcoff.em
ld/emultempl/m68kelf.em
ld/emultempl/mipsecoff.em
ld/emultempl/mipself.em
ld/emultempl/mmix-elfnmmo.em
ld/emultempl/mmixelf.em
ld/emultempl/mmo.em
ld/emultempl/needrelax.em
ld/emultempl/netbsd.em
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/emultempl/ppc32elf.em
ld/emultempl/ppc64elf.em
ld/emultempl/scoreelf.em
ld/emultempl/sh64elf.em
ld/emultempl/spuelf.em
ld/emultempl/sunos.em
ld/emultempl/ticoff.em
ld/emultempl/vanilla.em
ld/emultempl/vxworks.em
ld/emultempl/xtensaelf.em
ld/emultempl/z80.em
ld/genscripts.sh

index df983b14a8e14ad3507f05213b353adf38bcd423..9aa0d500aeea29bcb2f103b9399e13b055851f8b 100644 (file)
@@ -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_NAME}.c
 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 fccfc1e8bc51b606b590839cdd526ec511fa38ed..6ac460b3b20e0148d219bafde0d637bd1e7a8bf6 100644 (file)
@@ -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 d258acc3059fd3a5a506b1c3ec4d6e08c59d1f92..6380e4b6ba3d4a4e61cf8330effac31bd9c27e78 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 325ad23bae34a872f5bba6aea0110d25d561f76a..8ce0dabaecbd446b3d93298b4b2dc68d06d0e146 100644 (file)
@@ -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"
 
@@ -326,7 +326,7 @@ PARSE_AND_LIST_ARGS_CASES='
     case OPTION_USE_BLX:
       use_blx = 1;
       break;
-    
+
     case OPTION_VFP11_DENORM_FIX:
       if (strcmp (optarg, "none") == 0)
         vfp11_denorm_fix = BFD_ARM_VFP11_FIX_NONE;
index 9f24f18344ad5b6b545bfa0b4f3333ba01191592..2f17ec941298d1921b36551954db904505cbaa25 100644 (file)
 # 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"
 
-/* The fake file and it's corresponding section meant to hold 
+/* The fake file and it's corresponding section meant to hold
    the linker stubs if needed.  */
 
 static lang_input_statement_type *stub_file;
@@ -126,14 +126,14 @@ avr_elf_create_output_section_statements (void)
                                               ".trampolines");
   if (avr_stub_section == NULL)
     goto err_ret;
-  
+
   flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
            | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP);
   if (!bfd_set_section_flags (stub_file->the_bfd, avr_stub_section, flags))
     goto err_ret;
 
   avr_stub_section->alignment_power = 1;
-  
+
   ldlang_add_file (stub_file);
 
   return;
@@ -147,7 +147,7 @@ avr_elf_create_output_section_statements (void)
 
 static void
 avr_elf_finish (void)
-{ 
+{
   if (!avr_no_stubs)
     {
       /* Now build the linker stubs.  */
@@ -185,15 +185,15 @@ PARSE_AND_LIST_PROLOGUE='
 '
 
 PARSE_AND_LIST_LONGOPTS='
-  { "no-call-ret-replacement", no_argument, 
+  { "no-call-ret-replacement", no_argument,
      NULL, OPTION_NO_CALL_RET_REPLACEMENT},
-  { "pmem-wrap-around", required_argument, 
+  { "pmem-wrap-around", required_argument,
     NULL, OPTION_PMEM_WRAP_AROUND},
-  { "no-stubs", no_argument, 
+  { "no-stubs", no_argument,
     NULL, OPTION_NO_STUBS},
-  { "debug-stubs", no_argument, 
+  { "debug-stubs", no_argument,
     NULL, OPTION_DEBUG_STUBS},
-  { "debug-relax", no_argument, 
+  { "debug-relax", no_argument,
     NULL, OPTION_DEBUG_RELAX},
 '
 
@@ -227,7 +227,7 @@ PARSE_AND_LIST_OPTIONS='
 PARSE_AND_LIST_ARGS_CASES='
 
     case OPTION_PMEM_WRAP_AROUND:
-      { 
+      {
         /* This variable is defined in the bfd library.  */
         if ((!strcmp (optarg,"32k"))      || (!strcmp (optarg,"32K")))
           avr_pc_wrap_around = 32768;
index 34becadc383259e779b3efe08542a932e0289d7d..23d3849c5d70f27cd9caa15d9027c3e4cd7c4d4f 100644 (file)
@@ -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'                                 >> e${EMULATION_NAME}.c
 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 699903b37cdae06b6cb408709ce321e830165319..fd1a2eddbdbf0c7a3fe3507f9073bc65bb4802b2 100644 (file)
@@ -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"
 
@@ -90,4 +90,3 @@ PARSE_AND_LIST_ARGS_CASES='
 #
 LDEMUL_AFTER_PARSE=cr16elf_after_parse
 LDEMUL_BEFORE_ALLOCATION=cr16elf_before_allocation
-
index 2931ff0a16393bba76c80f0e3d97a52a4d4ac8c9..d306fd66043726a5adf2aa63b527c403e036801c 100644 (file)
@@ -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"
 
@@ -92,4 +92,3 @@ PARSE_AND_LIST_ARGS_CASES='
 #
 LDEMUL_AFTER_PARSE=crxelf_after_parse
 LDEMUL_BEFORE_ALLOCATION=crxelf_before_allocation
-
index f3cd9e088a96a50c00e89537cc1d46787e20931e..94486f81d74ae29e011936422ebd193eb4e36945 100644 (file)
@@ -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 a3af5cae438e86417ead2e4a32bc9e500e377c40..6261e1d617509758ab7ab81022e31c23c04c692b 100644 (file)
@@ -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_input_statement_type *entry)
 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 dt_needed *needed,
 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 (const char *path,
 
 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 char *path)
 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_input_statement_type *s)
 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,
@@ -1188,31 +1188,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)
            {
@@ -1227,7 +1227,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)
@@ -1247,7 +1247,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
@@ -1256,7 +1256,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;
 
@@ -1264,7 +1264,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)
            {
@@ -1282,7 +1282,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
          if (search != NULL)
            break;
 EOF
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
        }
 
       if (force < 2)
@@ -1296,7 +1296,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.  */
 
@@ -1377,7 +1377,7 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_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.  */
@@ -1478,7 +1478,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
@@ -1557,7 +1557,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.  */
 
@@ -1807,7 +1807,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)
@@ -1821,7 +1821,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)
@@ -1834,7 +1834,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;
 
@@ -1888,7 +1888,7 @@ echo '; }'                                                >> e${EMULATION_NAME}.c
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -1901,14 +1901,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";
@@ -1916,14 +1916,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";
@@ -1931,13 +1931,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";
@@ -1945,7 +1945,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";
 }
@@ -1957,12 +1957,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)
@@ -1983,7 +1983,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},
@@ -1994,12 +1994,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}
   };
 
@@ -2035,7 +2035,7 @@ gld${EMULATION_NAME}_handle_option (int optc)
 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;
@@ -2128,7 +2128,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)
@@ -2136,7 +2136,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;
@@ -2166,12 +2166,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;
@@ -2180,7 +2180,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)
@@ -2189,7 +2189,7 @@ gld${EMULATION_NAME}_list_options (FILE * 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"));
@@ -2213,23 +2213,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"));
@@ -2237,34 +2237,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 c6db28770548a569520a76ce4dd1f3ccb0b97776..e44bb9b9e107f053a8db58bea7ed8735a8f2b124 100644 (file)
 
 # 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 35621c39dbac3c2c5211bbdebe2d2263cd35b3ec..048ebbdafc3702f00a170c48e1a2e5b91ad02d19 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 900d9b65fe109c8419749de4a6bffad995bffa81..2669c0e059fae29e0f17fbcf40df901f035d78be 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 f8a8deac7c83aa0b267759c32407fb9022fd6361..1999ea89a85c43c9e88bb4b34f90f8d40ef6a97e 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 703e820200861af950655b76e6142f26a91a0e5e..f1e1c4507b42d83cc451117ff53e4f8d4c9bb197 100644 (file)
@@ -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 828560efc49446d103eb9ae20317140a4069d234..d562417607bb2018e56fcaed83744326fb41b0e5 100644 (file)
@@ -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 dcac9476546312b4bb233c711c1d347e4af760fc..b4a8f4e13fd4d07824da57e8eb92fec394f4c3a1 100644 (file)
@@ -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 9209c1a66224715710e59fb1cc7f283ebefe1869..aa4a088b1228036005174717b14fcb782dfbae8b 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 e3b2d5020e7c55fee23f73c0f0e0ac61b3c5aa93..1e9e755230194bd9f86eead79bfbee5fd7fc526e 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 1f0a3eec8184068728e47e86426fc7ed6f1b5fe1..03a0500f685b54a40a5c865a5c6aa9431602dd30 100644 (file)
@@ -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 11c6aba20095aae0f1efaf06be10d83520b19979..a79eb2c1a17757d2fbacec95b2a4096927b5db2f 100644 (file)
@@ -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 '; }'                                             >> e${EMULATION_NAME}.c
 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 cb64d850d4b7fcf96689207bb7f2cd3a7c45976a..d6a1d8acb785fa3cc0feff088fe5c2da586bf3a2 100644 (file)
@@ -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 1e6d060cb951c01da5c955b7d6f28f5ee81679a5..75a943a39193b8fae7758922090512afcfa2d1bb 100644 (file)
@@ -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 a850610d6f094d55db52db8ad661be0d4adb0b4c..e7a1be84fb4210ceaa9bc673c59d254b97f0851a 100644 (file)
@@ -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 eb93235f28a66989530d0565278635b263809ea2..9957268cbdfcf7db14273802569e4af09f789bbd 100644 (file)
@@ -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 855f8fc864e3e082203ee385e7d355ea52893a43..314f56063cd5042b5be88f3f9c12360e6ceb6a01 100644 (file)
@@ -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 660734790171162eec21d21910fab9b456a9ae84..8c4657730db72b79e7f5d19db79d725d240f4e48 100644 (file)
@@ -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 6eb95769adad91001a636b099af3e695c8394e41..c0d5928ee9a0f31b847ed3d24a96ee3b673c8230 100644 (file)
@@ -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 20158233fd9ef8e317797886a8add10239c671d8..6e25486aaf91a28db3b4a187335489bc214e8ba6 100644 (file)
@@ -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 9dd070a1f5b9d187061fb4a77e55d91138aab3d8..ddee01125bbe4feaa28a48ba9545ba910eb54b33 100644 (file)
@@ -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.
 
@@ -51,7 +51,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 #define bfd_arm_process_before_allocation \
        bfd_${EMULATION_NAME}_process_before_allocation
 #endif
+
 #include "sysdep.h"
 #include "bfd.h"
 #include "bfdlink.h"
@@ -1287,7 +1287,7 @@ gld_${EMULATION_NAME}_after_open (void)
                if ((sec->flags & SEC_CODE) && sec->reloc_count)
                  stub_sec = sec;
              }
-   
+
            if (is_imp && stub_sec)
              {
                long symsize;
@@ -1780,7 +1780,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive
           For backwards compatibility, libfoo.a needs to precede
           libfoo.dll and foo.dll in the search.  */
       { "lib%s.a", FALSE },
-      /* The 'native' spelling of an import lib name is "foo.lib".  */         
+      /* The 'native' spelling of an import lib name is "foo.lib".  */
       { "%s.lib", FALSE },
 #ifdef DLL_SUPPORT
       /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
@@ -1837,7 +1837,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive
 
   for (i = 0; libname_fmt[i].format; i++)
     {
-#ifdef DLL_SUPPORT 
+#ifdef DLL_SUPPORT
       if (libname_fmt[i].use_prefix)
        {
          if (!pe_dll_search_prefix)
@@ -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${EMULATION_NAME}.c
 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 e26dfb2417b7ff6958fac4163f94bca3697e6595..6a21bc7b99eacd7d7bdc928e7b7df5acefec76d2 100644 (file)
@@ -8,8 +8,8 @@ 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
-/* Copyright 2006, 2007 Free Software Foundation, Inc.   
+fragment <<EOF
+/* Copyright 2006, 2007 Free Software Foundation, Inc.
    Written by Kai Tietz, OneVision Software GmbH&CoKg.
 
    This file is part of the GNU Binutils.
@@ -1559,7 +1559,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive
           For backwards compatibility, libfoo.a needs to precede
           libfoo.dll and foo.dll in the search.  */
       { "lib%s.a", FALSE },
-      /* The 'native' spelling of an import lib name is "foo.lib".  */         
+      /* The 'native' spelling of an import lib name is "foo.lib".  */
       { "%s.lib", FALSE },
 #ifdef DLL_SUPPORT
       /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
@@ -1616,7 +1616,7 @@ gld_${EMULATION_NAME}_open_dynamic_archive
 
   for (i = 0; libname_fmt[i].format; i++)
     {
-#ifdef DLL_SUPPORT 
+#ifdef DLL_SUPPORT
       if (libname_fmt[i].use_prefix)
        {
          if (!pep_dll_search_prefix)
@@ -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${EMULATION_NAME}.c
 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 d28b9a61d92bfb015a69df4725b07f53e152f5af..0b8d887563618f3699145e36bbd937721b47e58d 100644 (file)
@@ -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 fd27e1b9e86e86b9057acebe9db17c6f4bf8168e..40e58910cd699817dce3d0bafe1f3f06a43595ee 100644 (file)
@@ -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 (*func) (lang_input_statement_type *))
 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 b3d502284c865fff63586c256f3313d65bf46cba..72c17d4a04ad1d8d5e4695eb442f0688a510a08f 100644 (file)
@@ -1,6 +1,6 @@
 # This shell script emits a C file. -*- C -*-
 #   Copyright 2006, 2007 Free Software Foundation, Inc.
-#   Contributed by: 
+#   Contributed by:
 #   Mei Ligang (ligang@sunnorth.com.cn)
 #   Pei-Lin Tsai (pltsai@sunplus.com)
 
@@ -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 ()
@@ -71,4 +71,3 @@ LDEMUL_AFTER_OPEN=score_elf_after_open
 
 # Replace the elf before_parse function with our own.
 LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
-
index 30dd68f169df2f6493607b21bd7b8ee8101e68f3..0433cf97243a9a59f7eb5607809467f27bb4df58 100644 (file)
@@ -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 2235143bd2b579c636ab996b4a966dd11e900701..ccbc0f771e1393c794253f981bbe6583fd9ec98f 100644 (file)
@@ -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 2aa23524ade497b84351d0e83951d104bb5640a2..00d949ffef7fef7ffdc91b780b631b9d1cb3656a 100644 (file)
@@ -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 '; }'                                                 >> e${EMULATION_NAME}
 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 003a666e474f41c9ca8fce924d5d945b104f2228..8860d5ac95d305bfc51a09d195cddd83e2d870fe 100644 (file)
@@ -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 2e26bd3efa700a791e817130eeb55578888ca3c7..8ed2a5abea06cfb9d46ea3a9dfecf51ba2c931c8 100644 (file)
@@ -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 e6131bbec5291964f4658431cab2842a5c03ce94..f6ad0b657d5272e42e1bbeb45dc109534165a34b 100644 (file)
 #
 
 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; do
   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 04f870a7e7ac8764a9c466f3c8a02279ca66f36d..04406a6bb3a36e22dc7dfa772b07073f1c0c214d 100644 (file)
@@ -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"
@@ -104,7 +104,7 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *internal_relocs = NULL;
   unsigned reloc_count;
+
   *error_message = "";
   insn_sec = bfd_get_section_by_name (abfd, insn_sec_name);
   if (insn_sec == NULL)
@@ -117,7 +117,7 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
       *error_message = _("file already has property tables");
       return FALSE;
     }
-  
+
   if (insn_sec->size != 0)
     {
       insn_contents = (bfd_byte *) bfd_malloc (insn_sec->size);
@@ -144,7 +144,7 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
       *error_message = _("could not create new section");
       goto cleanup;
     }
-  
+
   prop_sec->size = entry_count * 12;
   prop_contents = (bfd_byte *) bfd_zalloc (abfd, prop_sec->size);
   elf_section_data (prop_sec)->this_hdr.contents = prop_contents;
@@ -153,7 +153,7 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
      the number of relocations since it does not use reloc_count.  */
   elf_section_data (prop_sec)->rel_hdr.sh_entsize =
     sizeof (Elf32_External_Rela);
-  elf_section_data (prop_sec)->rel_hdr.sh_size = 
+  elf_section_data (prop_sec)->rel_hdr.sh_size =
     elf_section_data (insn_sec)->rel_hdr.sh_size;
 
   if (prop_contents == NULL && prop_sec->size != 0)
@@ -169,12 +169,12 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
       /* If there is already an internal_reloc, then save it so that the
         read_relocs function freshly allocates a copy.  */
       Elf_Internal_Rela *saved_relocs = elf_section_data (insn_sec)->relocs;
-      
+
       elf_section_data (insn_sec)->relocs = NULL;
-      internal_relocs = 
+      internal_relocs =
        _bfd_elf_link_read_relocs (abfd, insn_sec, NULL, NULL, FALSE);
       elf_section_data (insn_sec)->relocs = saved_relocs;
-      
+
       if (internal_relocs == NULL)
        {
          *error_message = _("out of memory");
@@ -188,7 +188,7 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
       elf_section_data (prop_sec)->relocs = internal_relocs;
       prop_sec->reloc_count = reloc_count;
     }
-  
+
   /* Now copy each insn table entry to the prop table entry with
      appropriate flags.  */
   for (entry = 0; entry < entry_count; ++entry)
@@ -218,7 +218,7 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
 
          rela = &internal_relocs[i];
 
-         /* If this relocation is to the .xt.insn section, 
+         /* If this relocation is to the .xt.insn section,
             change the section number and the offset.  */
          r_offset = rela->r_offset;
          r_offset += 4 * (r_offset / 8);
@@ -227,10 +227,10 @@ replace_insn_sec_with_prop_sec (bfd *abfd,
     }
 
   remove_section (abfd, insn_sec);
-  
+
   if (insn_contents)
     free (insn_contents);
-  
+
   return TRUE;
 
  cleanup:
@@ -258,7 +258,7 @@ replace_instruction_table_sections (bfd *abfd, asection *sec)
   char *prop_sec_name = NULL;
   char *owned_prop_sec_name = NULL;
   const char *sec_name;
-    
+
   sec_name = bfd_get_section_name (abfd, sec);
   if (strcmp (sec_name, INSN_SEC_BASE_NAME) == 0)
     {
@@ -297,7 +297,7 @@ elf_xtensa_after_open (void)
 {
   /* First call the ELF version.  */
   gld${EMULATION_NAME}_after_open ();
-  
+
   /* Now search the input files looking for instruction table sections.  */
   LANG_FOR_EACH_INPUT_STATEMENT (f)
     {
@@ -2024,4 +2024,3 @@ LDEMUL_BEFORE_PARSE=elf_xtensa_before_parse
 LDEMUL_AFTER_OPEN=elf_xtensa_after_open
 LDEMUL_CHOOSE_TARGET=elf_xtensa_choose_target
 LDEMUL_BEFORE_ALLOCATION=elf_xtensa_before_allocation
-
index 98b45787e4fcecde001edb7ac85f44ed39ea1813..7b17e8fc2b1a0c3883c569154820e7b71860666e 100644 (file)
@@ -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.  */
@@ -36,7 +36,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 /* Bitwise or of the machine types seen so far.  */
 static int result_mach_type;
 
-static void 
+static void
 ${LDEMUL_BEFORE_PARSE} (void)
 {
 #ifndef TARGET_                        /* I.e., if not generic.  */
@@ -53,19 +53,19 @@ ${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
   unsigned long mach_type;
 
   mach_type = bfd_get_mach (entry->the_bfd);
-  switch (mach_type) 
+  switch (mach_type)
     {
-    case bfd_mach_z80strict:      
-      result_mach_type |= M_Z80STRICT; 
+    case bfd_mach_z80strict:
+      result_mach_type |= M_Z80STRICT;
       break;
     case bfd_mach_z80:
-      result_mach_type |= M_Z80; 
+      result_mach_type |= M_Z80;
       break;
     case bfd_mach_z80full:
-      result_mach_type |= M_Z80FULL; 
+      result_mach_type |= M_Z80FULL;
       break;
     case bfd_mach_r800:
-      result_mach_type |= M_R800; 
+      result_mach_type |= M_R800;
       break;
     default:
       result_mach_type |= M_Z80ANY;
index f4c4709d694f44853ce330fec1aa9d42653391eb..17c516c479000049595ca0fdc55b366272eaa813 100755 (executable)
@@ -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