[ARC] Fix assembler relaxation.
[deliverable/binutils-gdb.git] / ld / emultempl / lnk960.em
index a868b539729fef1578430a5302a3f661c32d88ea..9f68f26275bd732a7f8841dc0807f42b19072d0c 100644 (file)
@@ -1,26 +1,26 @@
 # 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.
+   Copyright (C) 1991-2017 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, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 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"
@@ -93,7 +93,7 @@ lnk960_before_parse (void)
        einfo ("%P%F I960BASE and G960BASE not set\n");
     }
 
-  ldfile_add_library_path (concat (name, "/lib", NULL), 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;
 }
@@ -129,15 +129,73 @@ lnk960_after_parse (void)
   add_on (syslib_list, lang_input_file_is_search_file_enum);
 }
 
+/* Create a symbol with the given name with the value of the
+   address of first byte of the section named.
+
+   If the symbol already exists, then do nothing.  */
+
+static void
+symbol_at_beginning_of (const char *secname, const char *name)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE);
+  if (h == NULL)
+    einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+
+  if (h->type == bfd_link_hash_new
+      || h->type == bfd_link_hash_undefined)
+    {
+      asection *sec;
+
+      h->type = bfd_link_hash_defined;
+
+      sec = bfd_get_section_by_name (link_info.output_bfd, secname);
+      if (sec == NULL)
+       sec = bfd_abs_section_ptr;
+      h->u.def.value = 0;
+      h->u.def.section = sec;
+    }
+}
+
+/* Create a symbol with the given name with the value of the
+   address of the first byte after the end of the section named.
+
+   If the symbol already exists, then do nothing.  */
+
+static void
+symbol_at_end_of (const char *secname, const char *name)
+{
+  struct bfd_link_hash_entry *h;
+
+  h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE);
+  if (h == NULL)
+    einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+
+  if (h->type == bfd_link_hash_new
+      || h->type == bfd_link_hash_undefined)
+    {
+      asection *sec;
+
+      h->type = bfd_link_hash_defined;
+
+      sec = bfd_get_section_by_name (link_info.output_bfd, secname);
+      if (sec == NULL)
+       sec = bfd_abs_section_ptr;
+      h->u.def.value = sec->size;
+      h->u.def.section = sec;
+    }
+}
+
 static void
 lnk960_after_allocation (void)
 {
-  if (!link_info.relocatable)
+  if (!bfd_link_relocatable (&link_info))
     {
-      lang_abs_symbol_at_end_of (".text", "_etext");
-      lang_abs_symbol_at_end_of (".data", "_edata");
-      lang_abs_symbol_at_beginning_of (".bss", "_bss_start");
-      lang_abs_symbol_at_end_of (".bss", "_end");
+      symbol_at_end_of (".text", "_etext");
+      symbol_at_end_of (".data", "_edata");
+      symbol_at_beginning_of (".bss", "_bss_start");
+      symbol_at_end_of (".bss", "_end");
     }
 }
 
@@ -188,7 +246,7 @@ 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);
 }
 
@@ -209,22 +267,22 @@ static char *
 lnk960_get_script (int *isfile)
 EOF
 
-if test -n "$COMPILE_IN"
+if test x"$COMPILE_IN" = xyes
 then
 # Scripts compiled in.
 
 # 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;
 
-  if (link_info.relocatable && config.build_constructors)
+  if (bfd_link_relocatable (&link_info) && config.build_constructors)
     return
 EOF
 sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
-echo '  ; else if (link_info.relocatable) return'     >> e${EMULATION_NAME}.c
+echo '  ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xr                 >> e${EMULATION_NAME}.c
 echo '  ; else if (!config.text_read_only) return'     >> e${EMULATION_NAME}.c
 sed $sc ldscripts/${EMULATION_NAME}.xbn                >> e${EMULATION_NAME}.c
@@ -237,13 +295,13 @@ echo '; }'                                             >> e${EMULATION_NAME}.c
 else
 # Scripts read from the filesystem.
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 {
   *isfile = 1;
 
-  if (link_info.relocatable && config.build_constructors)
+  if (bfd_link_relocatable (&link_info) && config.build_constructors)
     return "ldscripts/${EMULATION_NAME}.xu";
-  else if (link_info.relocatable)
+  else if (bfd_link_relocatable (&link_info))
     return "ldscripts/${EMULATION_NAME}.xr";
   else if (!config.text_read_only)
     return "ldscripts/${EMULATION_NAME}.xbn";
@@ -256,7 +314,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_lnk960_emulation =
 {
@@ -264,7 +322,7 @@ 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,
@@ -284,6 +342,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
   NULL,        /* list options */
   NULL,        /* recognized file */
   NULL,        /* find_potential_libraries */
-  NULL /* new_vers_pattern */
+  NULL,        /* new_vers_pattern */
+  NULL /* extra_map_file_text */
 };
 EOF
This page took 0.0546 seconds and 4 git commands to generate.