PR ld/13909
[platform/upstream/binutils.git] / ld / emultempl / lnk960.em
index 2c294ec..7120329 100644 (file)
@@ -1,30 +1,31 @@
 # 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
-   Free Software Foundation, Inc.
+   Copyright 1991, 1992, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003,
+   2005, 2007, 2008 Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
-This file is part of GLD, the Gnu Linker.
+   This file is part of the GNU Binutils.
 
-GLD is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-GLD is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include "libiberty.h"
 #include "bfd.h"
-#include "sysdep.h"
 #include "bfdlink.h"
 
 /*#include "archures.h"*/
@@ -81,32 +82,6 @@ lnk960_syslib (char *name)
 }
 
 
-#ifdef GNU960
-
-static void
-lnk960_before_parse (void)
-{
-  static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
-  char **p;
-  char *env ;
-
-  for (p = env_variables; *p; p++)
-    {
-      env = (char *) getenv (*p);
-      if (env)
-       ldfile_add_library_path (concat (env, "/lib/libcoff", ""), FALSE);
-    }
-
-  env = (char *) getenv ("I960BASE");
-  if (env)
-    ldfile_add_library_path(concat (env, "/lib", ""), FALSE);
-
-  ldfile_output_architecture = bfd_arch_i960;
-  ldfile_output_machine = bfd_mach_i960_core;
-}
-
-#else  /* not GNU960 */
-
 static void
 lnk960_before_parse (void)
 {
@@ -119,15 +94,11 @@ lnk960_before_parse (void)
        einfo ("%P%F I960BASE and G960BASE not set\n");
     }
 
-
-  ldfile_add_library_path (concat (name, "/lib", ""), FALSE);
+  ldfile_add_library_path (concat (name, "/lib", (const char *) NULL), FALSE);
   ldfile_output_architecture = bfd_arch_i960;
   ldfile_output_machine = bfd_mach_i960_core;
 }
 
-#endif /* GNU960 */
-
-
 static void
 add_on (lib_list_type *list, lang_input_file_enum_type search)
 {
@@ -160,11 +131,6 @@ lnk960_after_parse (void)
 }
 
 static void
-lnk960_before_allocation (void)
-{
-}
-
-static void
 lnk960_after_allocation (void)
 {
   if (!link_info.relocatable)
@@ -223,19 +189,13 @@ lnk960_set_output_arch (void)
          break;
        }
     }
-  bfd_set_arch_mach (output_bfd, ldfile_output_architecture,
+  bfd_set_arch_mach (link_info.output_bfd, ldfile_output_architecture,
                     ldfile_output_machine);
 }
 
 static char *
 lnk960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
 {
-#ifdef GNU960
-
-  return bfd_make_targ_name (BFD_COFF_FORMAT, 0);
-
-#else
-
   char *from_outside = getenv (TARGET_ENVIRON);
   if (from_outside != (char *) NULL)
     return from_outside;
@@ -244,8 +204,6 @@ lnk960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
 #else
   return "coff-Intel-big";
 #endif
-#endif
-
 }
 
 static char *
@@ -259,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;
 
@@ -280,7 +238,7 @@ echo '; }'                                             >> e${EMULATION_NAME}.c
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
@@ -299,7 +257,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_lnk960_emulation =
 {
@@ -307,15 +265,15 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
   lnk960_syslib,
   lnk960_hll,
   lnk960_after_parse,
-  NULL,                        /* after_open */
+  after_open_default,
   lnk960_after_allocation,
   lnk960_set_output_arch,
   lnk960_choose_target,
-  lnk960_before_allocation,
+  before_allocation_default,
   lnk960_get_script,
   "lnk960",
   "",
-  NULL,        /* finish */
+  finish_default,
   NULL,        /* create output section statements */
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */