bfd/
[deliverable/binutils-gdb.git] / ld / emultempl / sunos.em
index 590736243ce2cfe668366c8915211be8328ef023..19f18931c8849390c5d28c972c435196f559df92 100644 (file)
@@ -1,10 +1,16 @@
 # This shell script emits a C file. -*- C -*-
 # It does some substitutions.
+if [ -z "$MACHINE" ]; then
+  OUTPUT_ARCH=${ARCH}
+else
+  OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
 cat >e${EMULATION_NAME}.c <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* SunOS emulation code for ${EMULATION_NAME}
-   Copyright (C) 1991, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+   Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    SunOS shared library support by Ian Lance Taylor <ian@cygnus.com>
 
@@ -22,26 +28,23 @@ 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.  */
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #define TARGET_IS_${EMULATION_NAME}
 
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
 #include "bfd.h"
 #include "sysdep.h"
 #include "bfdlink.h"
 #include "libiberty.h"
+#include "safe-ctype.h"
 
 #include "ld.h"
 #include "ldmain.h"
-#include "ldemul.h"
-#include "ldfile.h"
 #include "ldmisc.h"
 #include "ldexp.h"
 #include "ldlang.h"
+#include "ldfile.h"
+#include "ldemul.h"
 
 #ifdef HAVE_DIRENT_H
 # include <dirent.h>
@@ -58,36 +61,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 # endif
 #endif
 
-static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
-static void gld${EMULATION_NAME}_set_symbols PARAMS ((void));
-static void gld${EMULATION_NAME}_create_output_section_statements
-  PARAMS ((void));
 static void gld${EMULATION_NAME}_find_so
-  PARAMS ((lang_input_statement_type *));
+  (lang_input_statement_type *);
 static char *gld${EMULATION_NAME}_search_dir
-  PARAMS ((const char *, const char *, boolean *));
-static void gld${EMULATION_NAME}_after_open PARAMS ((void));
+  (const char *, const char *, bfd_boolean *);
 static void gld${EMULATION_NAME}_check_needed
-  PARAMS ((lang_input_statement_type *));
-static boolean gld${EMULATION_NAME}_search_needed
-  PARAMS ((const char *, const char *));
-static boolean gld${EMULATION_NAME}_try_needed
-  PARAMS ((const char *, const char *));
-static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
+  (lang_input_statement_type *);
+static bfd_boolean gld${EMULATION_NAME}_search_needed
+  (const char *, const char *);
+static bfd_boolean gld${EMULATION_NAME}_try_needed
+  (const char *, const char *);
 static void gld${EMULATION_NAME}_find_assignment
-  PARAMS ((lang_statement_union_type *));
-static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *));
+  (lang_statement_union_type *);
+static void gld${EMULATION_NAME}_find_exp_assignment
+  (etree_type *);
 static void gld${EMULATION_NAME}_count_need
-  PARAMS ((lang_input_statement_type *));
+  (lang_input_statement_type *);
 static void gld${EMULATION_NAME}_set_need
-  PARAMS ((lang_input_statement_type *));
-static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
+  (lang_input_statement_type *);
 
 static void
-gld${EMULATION_NAME}_before_parse()
+gld${EMULATION_NAME}_before_parse (void)
 {
-  ldfile_output_architecture = bfd_arch_${ARCH};
-  config.dynamic_link = true;
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
+  config.dynamic_link = TRUE;
+  config.has_shared = TRUE;
 }
 
 /* This is called after the command line arguments have been parsed,
@@ -96,11 +94,12 @@ gld${EMULATION_NAME}_before_parse()
    list.  */
 
 static void
-gld${EMULATION_NAME}_set_symbols ()
+gld${EMULATION_NAME}_set_symbols (void)
 {
 EOF
 if [ "x${host}" = "x${target}" ] ; then
-  if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
+  case " ${EMULATION_LIBPATH} " in
+  *" ${EMULATION_NAME} "*)
 cat >>e${EMULATION_NAME}.c <<EOF
   const char *env;
 
@@ -118,14 +117,15 @@ cat >>e${EMULATION_NAME}.c <<EOF
          if (c != NULL)
            *c++ = '\0';
          if (*l != '\0')
-           ldfile_add_library_path (l, false);
+           ldfile_add_library_path (l, FALSE);
          if (c == NULL)
            break;
          l = c;
        }
     }
 EOF
-  fi
+  ;;
+  esac
 fi
 cat >>e${EMULATION_NAME}.c <<EOF
 }
@@ -140,7 +140,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
    search it after including the .so file.  */
 
 static void
-gld${EMULATION_NAME}_create_output_section_statements ()
+gld${EMULATION_NAME}_create_output_section_statements (void)
 {
   lang_for_each_input_file (gld${EMULATION_NAME}_find_so);
 }
@@ -148,11 +148,10 @@ gld${EMULATION_NAME}_create_output_section_statements ()
 /* Search the directory for a .so file for each library search.  */
 
 static void
-gld${EMULATION_NAME}_find_so (inp)
-     lang_input_statement_type *inp;
+gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp)
 {
   search_dirs_type *search;
-  char *found;
+  char *found = NULL;
   char *alc;
   struct stat st;
 
@@ -165,7 +164,7 @@ gld${EMULATION_NAME}_find_so (inp)
 
   for (search = search_head; search != NULL; search = search->next)
     {
-      boolean found_static;
+      bfd_boolean found_static;
 
       found = gld${EMULATION_NAME}_search_dir (search->name, inp->filename,
                                               &found_static);
@@ -188,7 +187,7 @@ gld${EMULATION_NAME}_find_so (inp)
 
   /* Turn off the search_dirs_flag to prevent ldfile_open_file from
      searching for this file again.  */
-  inp->search_dirs_flag = false;
+  inp->search_dirs_flag = FALSE;
 
   free (found);
 
@@ -196,7 +195,7 @@ gld${EMULATION_NAME}_find_so (inp)
      found, add it to the list of input files.  */
   alc = (char *) xmalloc (strlen (inp->filename) + 1);
   strcpy (alc, inp->filename);
-  strstr (alc + strlen (search->name), ".so.")[2] = 'a';
+  strstr (alc + strlen (search->name), ".so")[2] = 'a';
   if (stat (alc, &st) != 0)
     free (alc);
   else
@@ -220,10 +219,8 @@ gld${EMULATION_NAME}_find_so (inp)
 /* Search a directory for a .so file.  */
 
 static char *
-gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
-     const char *dirname;
-     const char *filename;
-     boolean *found_static;
+gld${EMULATION_NAME}_search_dir
+  (const char *dirname, const char *filename, bfd_boolean *found_static)
 {
   int force_maj, force_min;
   const char *dot;
@@ -233,8 +230,12 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
   int max_maj, max_min;
   DIR *dir;
   struct dirent *entry;
+  unsigned int dirnamelen;
+  char *full_path;
+  int statval;
+  struct stat st;
 
-  *found_static = false;
+  *found_static = FALSE;
 
   force_maj = -1;
   force_min = -1;
@@ -265,7 +266,8 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
   dir = opendir (dirname);
   if (dir == NULL)
     return NULL;
-  
+  dirnamelen = strlen (dirname);
+
   while ((entry = readdir (dir)) != NULL)
     {
       const char *s;
@@ -278,16 +280,26 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
       if (dot == NULL
          && strcmp (entry->d_name + 3 + len, ".a") == 0)
        {
-         *found_static = true;
+         *found_static = TRUE;
          continue;
        }
 
-      if (strncmp (entry->d_name + 3 + len, ".so.", 4) != 0
-         || ! isdigit (entry->d_name[7 + len]))
+      /* We accept libfoo.so without a version number, even though the
+        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)
+       continue;
+      if (entry->d_name[6 + len] == '\0')
+       ;
+      else if (entry->d_name[6 + len] == '.'
+              && ISDIGIT (entry->d_name[7 + len]))
+       ;
+      else
        continue;
 
-      for (s = entry->d_name + 7 + len; *s != '\0'; s++)
-       if (*s != '.' && ! isdigit (*s))
+      for (s = entry->d_name + 6 + len; *s != '\0'; s++)
+       if (*s != '.' && ! ISDIGIT (*s))
          break;
       if (*s != '\0')
        continue;
@@ -303,6 +315,14 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
          || (force_min != -1 && force_min != found_min))
        continue;
 
+      /* Make sure the file really exists (ignore broken symlinks).  */
+      full_path = xmalloc (dirnamelen + 1 + strlen (entry->d_name) + 1);
+      sprintf (full_path, "%s/%s", dirname, entry->d_name);
+      statval = stat (full_path, &st);
+      free (full_path);
+      if (statval != 0)
+       continue;
+
       /* We've found a match for the name we are searching for.  See
         if this is the version we should use.  If the major and minor
         versions match, we use the last entry in alphabetical order;
@@ -336,17 +356,17 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
    between after_open and check_needed.  */
 
 static struct bfd_link_needed_list *global_needed;
-static boolean global_found;
+static bfd_boolean global_found;
 
 /* This is called after all the input files have been opened.  */
 
 static void
-gld${EMULATION_NAME}_after_open ()
+gld${EMULATION_NAME}_after_open (void)
 {
   struct bfd_link_needed_list *needed, *l;
 
   /* We only need to worry about this when doing a final link.  */
-  if (link_info.relocateable || link_info.shared)
+  if (link_info.relocatable || link_info.shared)
     return;
 
   /* Get the list of files which appear in ld_need entries in dynamic
@@ -375,7 +395,7 @@ gld${EMULATION_NAME}_after_open ()
 
       /* See if this file was included in the link explicitly.  */
       global_needed = l;
-      global_found = false;
+      global_found = FALSE;
       lang_for_each_input_file (gld${EMULATION_NAME}_check_needed);
       if (global_found)
        continue;
@@ -441,7 +461,8 @@ gld${EMULATION_NAME}_after_open ()
        }
 EOF
 if [ "x${host}" = "x${target}" ] ; then
-  if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
+  case " ${EMULATION_LIBPATH} " in
+  *" ${EMULATION_NAME} "*)
 cat >>e${EMULATION_NAME}.c <<EOF
       {
        const char *lib_path;
@@ -451,7 +472,8 @@ cat >>e${EMULATION_NAME}.c <<EOF
          continue;
       }
 EOF
-  fi
+  ;;
+  esac
 fi
 cat >>e${EMULATION_NAME}.c <<EOF
       if (command_line.rpath != NULL)
@@ -474,15 +496,13 @@ cat >>e${EMULATION_NAME}.c <<EOF
 
 /* Search for a needed file in a path.  */
 
-static boolean
-gld${EMULATION_NAME}_search_needed (path, name)
-     const char *path;
-     const char *name;
+static bfd_boolean
+gld${EMULATION_NAME}_search_needed (const char *path, const char *name)
 {
   const char *s;
 
   if (path == NULL || *path == '\0')
-    return false;
+    return FALSE;
   while (1)
     {
       const char *dir;
@@ -503,7 +523,7 @@ gld${EMULATION_NAME}_search_needed (path, name)
        }
 
       if (gld${EMULATION_NAME}_try_needed (dir, name))
-       return true;
+       return TRUE;
 
       if (dircopy != NULL)
        free (dircopy);
@@ -513,41 +533,39 @@ gld${EMULATION_NAME}_search_needed (path, name)
       path = s + 1;
     }
 
-  return false;          
+  return FALSE;
 }
 
 /* This function is called for each possible directory for a needed
    dynamic object.  */
 
-static boolean
-gld${EMULATION_NAME}_try_needed (dir, name)
-     const char *dir;
-     const char *name;
+static bfd_boolean
+gld${EMULATION_NAME}_try_needed (const char *dir, const char *name)
 {
   char *file;
   char *alc;
-  boolean ignore;
+  bfd_boolean ignore;
   bfd *abfd;
 
   file = gld${EMULATION_NAME}_search_dir (dir, name, &ignore);
   if (file == NULL)
-    return false;
+    return FALSE;
 
   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));
   if (abfd == NULL)
-    return false;
+    return FALSE;
   if (! bfd_check_format (abfd, bfd_object))
     {
       (void) bfd_close (abfd);
-      return false;
+      return FALSE;
     }
   if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0)
     {
       (void) bfd_close (abfd);
-      return false;
+      return FALSE;
     }
 
   /* We've found the needed dynamic object.  */
@@ -556,7 +574,7 @@ gld${EMULATION_NAME}_try_needed (dir, name)
   if (! bfd_link_add_symbols (abfd, &link_info))
     einfo ("%F%B: could not read symbols: %E\n", abfd);
 
-  return true;
+  return TRUE;
 }
 
 /* See if we have already included a needed object in the link.  This
@@ -564,15 +582,14 @@ gld${EMULATION_NAME}_try_needed (dir, name)
    dynamic object more than once.  */
 
 static void
-gld${EMULATION_NAME}_check_needed (s)
-     lang_input_statement_type *s;
+gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s)
 {
   if (s->filename == NULL)
     return;
   if (strncmp (global_needed->name, "-l", 2) != 0)
     {
       if (strcmp (s->filename, global_needed->name) == 0)
-       global_found = true;
+       global_found = TRUE;
     }
   else
     {
@@ -612,7 +629,7 @@ gld${EMULATION_NAME}_check_needed (s)
          || (smin != lmin && smin != -1 && lmin != -1))
        return;
 
-      global_found = true;
+      global_found = TRUE;
     }
 }
 
@@ -620,7 +637,7 @@ gld${EMULATION_NAME}_check_needed (s)
    to lang_for_each_statement.  Ick.  */
 
 static const char *find_assign;
-static boolean found_assign;
+static bfd_boolean found_assign;
 
 /* We need to use static variables to pass information around the call
    to lang_for_each_input_file.  Ick.  */
@@ -640,7 +657,7 @@ static bfd_byte *need_pnames;
    sections, but before any sizes or addresses have been set.  */
 
 static void
-gld${EMULATION_NAME}_before_allocation ()
+gld${EMULATION_NAME}_before_allocation (void)
 {
   struct bfd_link_hash_entry *hdyn = NULL;
   asection *sneed;
@@ -650,11 +667,11 @@ gld${EMULATION_NAME}_before_allocation ()
   /* 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.relocateable && ! entry_from_cmdline)
+  if (! link_info.shared && ! link_info.relocatable && ! entry_from_cmdline)
     {
       struct bfd_link_hash_entry *h;
-      
-      for (h = link_info.hash->undefs; h != NULL; h = h->next)
+
+      for (h = link_info.hash->undefs; h != NULL; h = h->u.undef.next)
        {
          if (h->type == bfd_link_hash_undefined
              && h->u.undef.abfd != NULL
@@ -663,11 +680,11 @@ gld${EMULATION_NAME}_before_allocation ()
              && strcmp (h->root.string, "__GLOBAL_OFFSET_TABLE_") != 0)
            {
              find_assign = h->root.string;
-             found_assign = false;
+             found_assign = FALSE;
              lang_for_each_statement (gld${EMULATION_NAME}_find_assignment);
              if (! found_assign)
                {
-                 link_info.shared = true;
+                 link_info.shared = TRUE;
                  break;
                }
            }
@@ -679,7 +696,7 @@ gld${EMULATION_NAME}_before_allocation ()
       lang_output_section_statement_type *os;
 
       /* Set the .text section to start at 0x20, not 0x2020.  FIXME:
-         This is too magical.  */
+        This is too magical.  */
       os = lang_output_section_statement_lookup (".text");
       if (os->addr_tree == NULL)
        os->addr_tree = exp_intop (0x20);
@@ -691,10 +708,10 @@ gld${EMULATION_NAME}_before_allocation ()
      one.  We need to create the symbol before calling
      size_dynamic_sections, although we can't set the value until
      afterward.  */
-  if (! link_info.relocateable)
+  if (! link_info.relocatable)
     {
-      hdyn = bfd_link_hash_lookup (link_info.hash, "__DYNAMIC", true, false,
-                                  false);
+      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,
@@ -727,7 +744,7 @@ gld${EMULATION_NAME}_before_allocation ()
         dynamic object.  */
       ASSERT (need_entries != 0);
 
-      sneed->_raw_size = need_size;
+      sneed->size = need_size;
       sneed->contents = (bfd_byte *) xmalloc (need_size);
 
       need_contents = sneed->contents;
@@ -747,7 +764,7 @@ gld${EMULATION_NAME}_before_allocation ()
         option.  */
       if (command_line.rpath)
        {
-         srules->_raw_size = strlen (command_line.rpath);
+         srules->size = strlen (command_line.rpath);
          srules->contents = (bfd_byte *) command_line.rpath;
        }
       else
@@ -759,7 +776,7 @@ gld${EMULATION_NAME}_before_allocation ()
          for (search = search_head; search != NULL; search = search->next)
            if (search->cmdline)
              size += strlen (search->name) + 1;
-         srules->_raw_size = size;
+         srules->size = size;
          if (size > 0)
            {
              char *p;
@@ -784,7 +801,7 @@ gld${EMULATION_NAME}_before_allocation ()
   /* 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.relocateable)
+  if (! link_info.relocatable)
     {
       hdyn->type = bfd_link_hash_defined;
       hdyn->u.def.value = 0;
@@ -793,6 +810,8 @@ gld${EMULATION_NAME}_before_allocation ()
       else
        hdyn->u.def.section = bfd_abs_section_ptr;
     }
+
+  before_allocation_default ();
 }
 
 /* This is called by the before_allocation routine via
@@ -803,8 +822,7 @@ gld${EMULATION_NAME}_before_allocation ()
    symbols which are referred to by dynamic objects.  */
 
 static void
-gld${EMULATION_NAME}_find_assignment (s)
-     lang_statement_union_type *s;
+gld${EMULATION_NAME}_find_assignment (lang_statement_union_type *s)
 {
   if (s->header.type == lang_assignment_statement_enum
       && (find_assign == NULL || ! found_assign))
@@ -814,8 +832,7 @@ gld${EMULATION_NAME}_find_assignment (s)
 /* Look through an expression for an assignment statement.  */
 
 static void
-gld${EMULATION_NAME}_find_exp_assignment (exp)
-     etree_type *exp;
+gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp)
 {
   switch (exp->type.node_class)
     {
@@ -823,7 +840,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp)
       if (find_assign != NULL)
        {
          if (strcmp (find_assign, exp->assign.dst) == 0)
-           found_assign = true;
+           found_assign = TRUE;
          return;
        }
 
@@ -863,8 +880,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp)
    for more information.  */
 
 static void
-gld${EMULATION_NAME}_count_need (inp)
-     lang_input_statement_type *inp;
+gld${EMULATION_NAME}_count_need (lang_input_statement_type *inp)
 {
   if (inp->the_bfd != NULL
       && (inp->the_bfd->flags & DYNAMIC) != 0)
@@ -885,8 +901,7 @@ gld${EMULATION_NAME}_count_need (inp)
 /* Fill in the contents of the .need section.  */
 
 static void
-gld${EMULATION_NAME}_set_need (inp)
-     lang_input_statement_type *inp;
+gld${EMULATION_NAME}_set_need (lang_input_statement_type *inp)
 {
   if (inp->the_bfd != NULL
       && (inp->the_bfd->flags & DYNAMIC) != 0)
@@ -904,7 +919,7 @@ gld${EMULATION_NAME}_set_need (inp)
          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);
-         strcpy (need_pnames, inp->filename);
+         strcpy ((char *) need_pnames, inp->filename);
        }
       else
        {
@@ -919,7 +934,7 @@ gld${EMULATION_NAME}_set_need (inp)
            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);
-         strcpy (need_pnames, inp->local_sym_name + 2);
+         strcpy ((char *) need_pnames, inp->local_sym_name + 2);
        }
 
       c = (need_pinfo - need_contents) / NEED_ENTRY_SIZE;
@@ -930,13 +945,12 @@ gld${EMULATION_NAME}_set_need (inp)
                    need_pinfo + 12);
 
       need_pinfo += NEED_ENTRY_SIZE;
-      need_pnames += strlen (need_pnames) + 1;
+      need_pnames += strlen ((char *) need_pnames) + 1;
     }
 }
 
 static char *
-gld${EMULATION_NAME}_get_script(isfile)
-     int *isfile;
+gld${EMULATION_NAME}_get_script (int *isfile)
 EOF
 
 if test -n "$COMPILE_IN"
@@ -944,39 +958,36 @@ then
 # Scripts compiled in.
 
 # sed commands to quote an ld script as a C string.
-sc='s/["\\]/\\&/g
-s/$/\\n\\/
-1s/^/"/
-$s/$/n"/
-'
+sc="-f stringify.sed"
 
 cat >>e${EMULATION_NAME}.c <<EOF
-{                           
+{
   *isfile = 0;
 
-  if (link_info.relocateable == true && config.build_constructors == true)
-    return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
-  else if (link_info.relocateable == true)
-    return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
-  else if (!config.text_read_only)
-    return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
-  else if (!config.magic_demand_paged)
-    return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
-  else
-    return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
-}
+  if (link_info.relocatable && 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
+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
+echo '  ; else if (!config.magic_demand_paged) return'     >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xn                     >> e${EMULATION_NAME}.c
+echo '  ; else return'                                     >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.x                      >> e${EMULATION_NAME}.c
+echo '; }'                                                 >> e${EMULATION_NAME}.c
 
 else
 # Scripts read from the filesystem.
 
 cat >>e${EMULATION_NAME}.c <<EOF
-{                           
+{
   *isfile = 1;
 
-  if (link_info.relocateable == true && config.build_constructors == true)
+  if (link_info.relocatable && config.build_constructors)
     return "ldscripts/${EMULATION_NAME}.xu";
-  else if (link_info.relocateable == true)
+  else if (link_info.relocatable)
     return "ldscripts/${EMULATION_NAME}.xr";
   else if (!config.text_read_only)
     return "ldscripts/${EMULATION_NAME}.xbn";
@@ -991,7 +1002,7 @@ fi
 
 cat >>e${EMULATION_NAME}.c <<EOF
 
-struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
+struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
 {
   gld${EMULATION_NAME}_before_parse,
   syslib_default,
@@ -1002,13 +1013,22 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   gld${EMULATION_NAME}_before_allocation,
+  do_assignments_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL, /* finish */
+  finish_default,
   gld${EMULATION_NAME}_create_output_section_statements,
-  NULL, /* open_dynamic_library */
-  NULL, /* place_orphan */
-  gld${EMULATION_NAME}_set_symbols
+  NULL,        /* open dynamic archive */
+  NULL,        /* place orphan */
+  gld${EMULATION_NAME}_set_symbols,
+  NULL,        /* parse args */
+  NULL,        /* add_options */
+  NULL,        /* handle_option */
+  NULL,        /* unrecognized file */
+  NULL,        /* list options */
+  NULL,        /* recognized file */
+  NULL,        /* find_potential_libraries */
+  NULL /* new_vers_pattern */
 };
 EOF
This page took 0.034863 seconds and 4 git commands to generate.