Use %pA and %pB in messages rather than %A and %B
[deliverable/binutils-gdb.git] / ld / emultempl / sunos.em
index cc192012df7edd1e0a2935a65f91423ef1115c56..daa94efec0e3103bb51a23d002bd28ed584a42e2 100644 (file)
@@ -5,35 +5,35 @@ 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}
-   Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
-   2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1991-2018 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    SunOS shared library support by Ian Lance Taylor <ian@cygnus.com>
 
-This file is part of GLD, the Gnu Linker.
+   This file is part of the GNU Binutils.
 
-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 2 of the License, 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.
 
-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.
+   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 this program; if not, write to the Free Software
-Foundation, Inc., 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.  */
 
 #define TARGET_IS_${EMULATION_NAME}
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "bfdlink.h"
 #include "libiberty.h"
 #include "safe-ctype.h"
@@ -84,7 +84,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
   ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
-  config.dynamic_link = TRUE;
+  input_flags.dynamic = TRUE;
   config.has_shared = TRUE;
 }
 
@@ -100,7 +100,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");
@@ -127,7 +127,7 @@ EOF
   ;;
   esac
 fi
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 }
 
 /* Despite the name, we use this routine to search for dynamic
@@ -155,12 +155,12 @@ gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp)
   char *alc;
   struct stat st;
 
-  if (! inp->search_dirs_flag
-      || ! inp->is_archive
-      || ! inp->dynamic)
+  if (! inp->flags.search_dirs
+      || ! inp->flags.maybe_archive
+      || ! inp->flags.dynamic)
     return;
 
-  ASSERT (strncmp (inp->local_sym_name, "-l", 2) == 0);
+  ASSERT (CONST_STRNEQ (inp->local_sym_name, "-l"));
 
   for (search = search_head; search != NULL; search = search->next)
     {
@@ -187,7 +187,7 @@ gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp)
 
   /* Turn off the search_dirs_flag to prevent ldfile_open_file from
      searching for this file again.  */
-  inp->search_dirs_flag = FALSE;
+  inp->flags.search_dirs = FALSE;
 
   free (found);
 
@@ -273,7 +273,7 @@ gld${EMULATION_NAME}_search_dir
       const char *s;
       int found_maj, found_min;
 
-      if (strncmp (entry->d_name, "lib", 3) != 0
+      if (! CONST_STRNEQ (entry->d_name, "lib")
          || strncmp (entry->d_name + 3, filename, len) != 0)
        continue;
 
@@ -288,7 +288,7 @@ gld${EMULATION_NAME}_search_dir
         native linker does not.  This is more convenient for packages
         which just generate .so files for shared libraries, as on ELF
         systems.  */
-      if (strncmp (entry->d_name + 3 + len, ".so", 3) != 0)
+      if (! CONST_STRNEQ (entry->d_name + 3 + len, ".so"))
        continue;
       if (entry->d_name[6 + len] == '\0')
        ;
@@ -365,8 +365,10 @@ gld${EMULATION_NAME}_after_open (void)
 {
   struct bfd_link_needed_list *needed, *l;
 
+  after_open_default ();
+
   /* We only need to worry about this when doing a final link.  */
-  if (link_info.relocatable || link_info.shared)
+  if (bfd_link_relocatable (&link_info) || bfd_link_pic (&link_info))
     return;
 
   /* Get the list of files which appear in ld_need entries in dynamic
@@ -377,7 +379,7 @@ gld${EMULATION_NAME}_after_open (void)
      include another without requiring special action by the person
      doing the link.  Note that the needed list can actually grow
      while we are stepping through this loop.  */
-  needed = bfd_sunos_get_needed_list (output_bfd, &link_info);
+  needed = bfd_sunos_get_needed_list (link_info.output_bfd, &link_info);
   for (l = needed; l != NULL; l = l->next)
     {
       struct bfd_link_needed_list *ll;
@@ -400,11 +402,11 @@ gld${EMULATION_NAME}_after_open (void)
       if (global_found)
        continue;
 
-      if (strncmp (lname, "-l", 2) != 0)
+      if (! CONST_STRNEQ (lname, "-l"))
        {
          bfd *abfd;
 
-         abfd = bfd_openr (lname, bfd_get_target (output_bfd));
+         abfd = bfd_openr (lname, bfd_get_target (link_info.output_bfd));
          if (abfd != NULL)
            {
              if (! bfd_check_format (abfd, bfd_object))
@@ -425,11 +427,11 @@ gld${EMULATION_NAME}_after_open (void)
            {
              /* We've found the needed dynamic object.  */
              if (! bfd_link_add_symbols (abfd, &link_info))
-               einfo ("%F%B: could not read symbols: %E\n", abfd);
+               einfo (_("%F%pB: error adding symbols: %E\n"), abfd);
            }
          else
            {
-             einfo ("%P: warning: %s, needed by %B, not found\n",
+             einfo (_("%P: warning: %s, needed by %pB, not found\n"),
                     lname, l->by);
            }
 
@@ -463,7 +465,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;
 
@@ -475,7 +477,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)
@@ -489,7 +491,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
            continue;
        }
 
-      einfo ("%P: warning: %s, needed by %B, not found\n",
+      einfo (_("%P: warning: %s, needed by %pB, not found\n"),
             l->name, l->by);
     }
 }
@@ -554,7 +556,7 @@ gld${EMULATION_NAME}_try_needed (const char *dir, const char *name)
   alc = (char *) xmalloc (strlen (dir) + strlen (file) + 2);
   sprintf (alc, "%s/%s", dir, file);
   free (file);
-  abfd = bfd_openr (alc, bfd_get_target (output_bfd));
+  abfd = bfd_openr (alc, bfd_get_target (link_info.output_bfd));
   if (abfd == NULL)
     return FALSE;
   if (! bfd_check_format (abfd, bfd_object))
@@ -572,7 +574,7 @@ gld${EMULATION_NAME}_try_needed (const char *dir, const char *name)
 
   /* Add this file into the symbol table.  */
   if (! bfd_link_add_symbols (abfd, &link_info))
-    einfo ("%F%B: could not read symbols: %E\n", abfd);
+    einfo (_("%F%pB: error adding symbols: %E\n"), abfd);
 
   return TRUE;
 }
@@ -586,7 +588,7 @@ gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
 {
   if (s->filename == NULL)
     return;
-  if (strncmp (global_needed->name, "-l", 2) != 0)
+  if (! CONST_STRNEQ (global_needed->name, "-l"))
     {
       if (strcmp (s->filename, global_needed->name) == 0)
        global_found = TRUE;
@@ -605,7 +607,7 @@ gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
       else
        ++sname;
 
-      if (strncmp (sname, "lib", 3) != 0)
+      if (! CONST_STRNEQ (sname, "lib"))
        return;
       sname += 3;
 
@@ -667,7 +669,9 @@ gld${EMULATION_NAME}_before_allocation (void)
   /* The SunOS native linker creates a shared library whenever there
      are any undefined symbols in a link, unless -e is used.  This is
      pretty weird, but we are compatible.  */
-  if (! link_info.shared && ! link_info.relocatable && ! entry_from_cmdline)
+  if (! bfd_link_pic (&link_info)
+      && !bfd_link_relocatable (&link_info)
+      && ! entry_from_cmdline)
     {
       struct bfd_link_hash_entry *h;
 
@@ -684,20 +688,20 @@ gld${EMULATION_NAME}_before_allocation (void)
              lang_for_each_statement (gld${EMULATION_NAME}_find_assignment);
              if (! found_assign)
                {
-                 link_info.shared = TRUE;
+                 link_info.type = type_dll;
                  break;
                }
            }
        }
     }
 
-  if (link_info.shared)
+  if (bfd_link_pic (&link_info))
     {
       lang_output_section_statement_type *os;
 
       /* Set the .text section to start at 0x20, not 0x2020.  FIXME:
         This is too magical.  */
-      os = lang_output_section_statement_lookup (".text");
+      os = lang_output_section_statement_lookup (".text", 0, TRUE);
       if (os->addr_tree == NULL)
        os->addr_tree = exp_intop (0x20);
     }
@@ -708,15 +712,15 @@ gld${EMULATION_NAME}_before_allocation (void)
      one.  We need to create the symbol before calling
      size_dynamic_sections, although we can't set the value until
      afterward.  */
-  if (! link_info.relocatable)
+  if (!bfd_link_relocatable (&link_info))
     {
       hdyn = bfd_link_hash_lookup (link_info.hash, "__DYNAMIC", TRUE, FALSE,
                                   FALSE);
       if (hdyn == NULL)
-       einfo ("%P%F: bfd_link_hash_lookup: %E\n");
-      if (! bfd_sunos_record_link_assignment (output_bfd, &link_info,
+       einfo (_("%P%F: bfd_link_hash_lookup: %E\n"));
+      if (! bfd_sunos_record_link_assignment (link_info.output_bfd, &link_info,
                                              "__DYNAMIC"))
-       einfo ("%P%F: failed to record assignment to __DYNAMIC: %E\n");
+       einfo (_("%P%F: failed to record assignment to __DYNAMIC: %E\n"));
     }
 
   /* If we are going to make any variable assignments, we need to let
@@ -726,9 +730,9 @@ gld${EMULATION_NAME}_before_allocation (void)
 
   /* Let the backend linker work out the sizes of any sections
      required by dynamic linking.  */
-  if (! bfd_sunos_size_dynamic_sections (output_bfd, &link_info, &sdyn,
-                                        &sneed, &srules))
-    einfo ("%P%F: failed to set dynamic section sizes: %E\n");
+  if (! bfd_sunos_size_dynamic_sections (link_info.output_bfd, &link_info,
+                                        &sdyn, &sneed, &srules))
+    einfo (_("%P%F: failed to set dynamic section sizes: %E\n"));
 
   if (sneed != NULL)
     {
@@ -801,7 +805,7 @@ gld${EMULATION_NAME}_before_allocation (void)
   /* We must assign a value to __DYNAMIC.  It should be zero if we are
      not doing a dynamic link, or the start of the .dynamic section if
      we are doing one.  */
-  if (! link_info.relocatable)
+  if (!bfd_link_relocatable (&link_info))
     {
       hdyn->type = bfd_link_hash_defined;
       hdyn->u.def.value = 0;
@@ -810,6 +814,8 @@ gld${EMULATION_NAME}_before_allocation (void)
       else
        hdyn->u.def.section = bfd_abs_section_ptr;
     }
+
+  before_allocation_default ();
 }
 
 /* This is called by the before_allocation routine via
@@ -844,9 +850,10 @@ gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp)
 
       if (strcmp (exp->assign.dst, ".") != 0)
        {
-         if (! bfd_sunos_record_link_assignment (output_bfd, &link_info,
+         if (! bfd_sunos_record_link_assignment (link_info.output_bfd,
+                                                 &link_info,
                                                  exp->assign.dst))
-           einfo ("%P%F: failed to record assignment to %s: %E\n",
+           einfo (_("%P%F: failed to record assignment to %s: %E\n"),
                   exp->assign.dst);
        }
       gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src);
@@ -885,7 +892,7 @@ gld${EMULATION_NAME}_count_need (lang_input_statement_type *inp)
     {
       ++need_entries;
       need_size += NEED_ENTRY_SIZE;
-      if (! inp->is_archive)
+      if (! inp->flags.maybe_archive)
        need_size += strlen (inp->filename) + 1;
       else
        {
@@ -911,12 +918,13 @@ gld${EMULATION_NAME}_set_need (lang_input_statement_type *inp)
         Instead, we use offsets, and rely on the BFD backend to
         finish the section up correctly.  FIXME: Talk about lack of
         referential locality.  */
-      bfd_put_32 (output_bfd, need_pnames - need_contents, need_pinfo);
-      if (! inp->is_archive)
+      bfd_put_32 (link_info.output_bfd, need_pnames - need_contents,
+                 need_pinfo);
+      if (! inp->flags.maybe_archive)
        {
-         bfd_put_32 (output_bfd, (bfd_vma) 0, need_pinfo + 4);
-         bfd_put_16 (output_bfd, (bfd_vma) 0, need_pinfo + 8);
-         bfd_put_16 (output_bfd, (bfd_vma) 0, need_pinfo + 10);
+         bfd_put_32 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 4);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 8);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 10);
          strcpy ((char *) need_pnames, inp->filename);
        }
       else
@@ -924,22 +932,23 @@ gld${EMULATION_NAME}_set_need (lang_input_statement_type *inp)
          char *verstr;
          int maj, min;
 
-         bfd_put_32 (output_bfd, (bfd_vma) 0x80000000, need_pinfo + 4);
+         bfd_put_32 (link_info.output_bfd, (bfd_vma) 0x80000000,
+                     need_pinfo + 4);
          maj = 0;
          min = 0;
          verstr = strstr (inp->filename, ".so.");
          if (verstr != NULL)
            sscanf (verstr, ".so.%d.%d", &maj, &min);
-         bfd_put_16 (output_bfd, (bfd_vma) maj, need_pinfo + 8);
-         bfd_put_16 (output_bfd, (bfd_vma) min, need_pinfo + 10);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) maj, need_pinfo + 8);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) min, need_pinfo + 10);
          strcpy ((char *) need_pnames, inp->local_sym_name + 2);
        }
 
       c = (need_pinfo - need_contents) / NEED_ENTRY_SIZE;
       if (c + 1 >= need_entries)
-       bfd_put_32 (output_bfd, (bfd_vma) 0, need_pinfo + 12);
+       bfd_put_32 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 12);
       else
-       bfd_put_32 (output_bfd, (bfd_vma) (c + 1) * NEED_ENTRY_SIZE,
+       bfd_put_32 (link_info.output_bfd, (bfd_vma) (c + 1) * NEED_ENTRY_SIZE,
                    need_pinfo + 12);
 
       need_pinfo += NEED_ENTRY_SIZE;
@@ -951,22 +960,22 @@ static char *
 gld${EMULATION_NAME}_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
@@ -979,13 +988,13 @@ echo '; }'                                                 >> e${EMULATION_NAME}
 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";
@@ -998,7 +1007,7 @@ EOF
 
 fi
 
-cat >>e${EMULATION_NAME}.c <<EOF
+fragment <<EOF
 
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
@@ -1007,6 +1016,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   after_parse_default,
   gld${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
@@ -1014,7 +1024,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL,        /* finish */
+  finish_default,
   gld${EMULATION_NAME}_create_output_section_statements,
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
@@ -1026,6 +1036,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_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.031425 seconds and 4 git commands to generate.