* elflink.h (elf_bfd_final_link): Check if dynobj is not NULL
[binutils-gdb.git] / ld / mpw-eppcmac.c
index 99d2b4dc05eae9ae02ddf18c9c5e6799d9958ee7..12780975a199f8fcf2cd787b52fb559e3730d3e8 100644 (file)
@@ -1,7 +1,8 @@
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* AIX emulation code for ppcmacos
-   Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
+   Copyright 1991, 1993, 1995, 1996, 1997, 2000, 2001
+   Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    AIX support by Ian Lance Taylor <ian@cygnus.com>
 
@@ -26,20 +27,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "bfd.h"
 #include "sysdep.h"
 #include "libiberty.h"
+#include "safe-ctype.h"
 #include "getopt.h"
 #include "bfdlink.h"
 
-#include <ctype.h>
-
 #include "ld.h"
 #include "ldmain.h"
-#include "ldemul.h"
-#include "ldfile.h"
 #include "ldmisc.h"
 #include "ldexp.h"
 #include "ldlang.h"
 #include "ldctor.h"
 #include "ldgram.h"
+#include "ldfile.h"
+#include "ldemul.h"
 
 static void gldppcmacos_before_parse PARAMS ((void));
 static int gldppcmacos_parse_args PARAMS ((int, char **));
@@ -165,6 +165,7 @@ gldppcmacos_parse_args (argc, argv)
     {"bmodtype", required_argument, NULL, OPTION_MODTYPE},
     {"bnoautoimp", no_argument, NULL, OPTION_NOAUTOIMP},
     {"bnodelcsect", no_argument, NULL, OPTION_IGNORE},
+    {"bnoentry", no_argument, NULL, OPTION_IGNORE},
     {"bnogc", no_argument, &gc, 0},
     {"bnso", no_argument, NULL, OPTION_NOAUTOIMP},
     {"bnostrcmpct", no_argument, NULL, OPTION_NOSTRCMPCT},
@@ -228,7 +229,7 @@ gldppcmacos_parse_args (argc, argv)
     case 'D':
       val = strtol (optarg, &end, 0);
       if (*end != '\0')
-       einfo ("%P: warning: ignoring invalid -D number %s\n", optarg);
+       einfo (_("%P: warning: ignoring invalid -D number %s\n"), optarg);
       else if (val != -1)
        lang_section_start (".data", exp_intop (val));
       break;
@@ -237,7 +238,7 @@ gldppcmacos_parse_args (argc, argv)
       val = strtoul (optarg, &end, 0);
       if (*end != '\0'
          || (val & (val - 1)) != 0)
-       einfo ("%P: warning: ignoring invalid -H number %s\n", optarg);
+       einfo (_("%P: warning: ignoring invalid -H number %s\n"), optarg);
       else
        file_align = val;
       break;
@@ -303,7 +304,7 @@ gldppcmacos_parse_args (argc, argv)
     case OPTION_MAXDATA:
       val = strtoul (optarg, &end, 0);
       if (*end != '\0')
-       einfo ("%P: warning: ignoring invalid -bmaxdata number %s\n",
+       einfo (_("%P: warning: ignoring invalid -bmaxdata number %s\n"),
               optarg);
       else
        maxdata = val;
@@ -312,7 +313,7 @@ gldppcmacos_parse_args (argc, argv)
     case OPTION_MAXSTACK:
       val = strtoul (optarg, &end, 0);
       if (*end != '\0')
-       einfo ("%P: warning: ignoring invalid -bmaxstack number %s\n",
+       einfo (_("%P: warning: ignoring invalid -bmaxstack number %s\n"),
               optarg);
       else
        maxstack = val;
@@ -325,7 +326,7 @@ gldppcmacos_parse_args (argc, argv)
          ++optarg;
        }
       if (*optarg == '\0' || optarg[1] == '\0')
-       einfo ("%P: warning: ignoring invalid module type %s\n", optarg);
+       einfo (_("%P: warning: ignoring invalid module type %s\n"), optarg);
       else
        modtype = (*optarg << 8) | optarg[1];
       break;
@@ -345,7 +346,7 @@ gldppcmacos_parse_args (argc, argv)
          expression.  */
       val = strtoul (optarg, &end, 0);
       if (*end != '\0')
-       einfo ("%P: warning: ignoring invalid -pD number %s\n", optarg);
+       einfo (_("%P: warning: ignoring invalid -pD number %s\n"), optarg);
       else
        {
          etree_type *t;
@@ -368,7 +369,7 @@ gldppcmacos_parse_args (argc, argv)
          within the file.  */
       val = strtoul (optarg, &end, 0);
       if (*end != '\0')
-       einfo ("%P: warning: ignoring invalid -pT number %s\n", optarg);
+       einfo (_("%P: warning: ignoring invalid -pT number %s\n"), optarg);
       else
        {
          etree_type *t;
@@ -395,6 +396,45 @@ gldppcmacos_parse_args (argc, argv)
   return 1;
 }
 
+/* This is called when an input file can not be recognized as a BFD
+   object or an archive.  If the file starts with #!, we must treat it
+   as an import file.  This is for AIX compatibility.  */
+
+static boolean
+gldppcmacos_unrecognized_file (entry)
+     lang_input_statement_type *entry;
+{
+  FILE *e;
+  boolean ret;
+
+  e = fopen (entry->filename, FOPEN_RT);
+  if (e == NULL)
+    return false;
+
+  ret = false;
+
+  if (getc (e) == '#' && getc (e) == '!')
+    {
+      struct filelist *n;
+      struct filelist **flpp;
+
+      n = (struct filelist *) xmalloc (sizeof (struct filelist));
+      n->next = NULL;
+      n->name = entry->filename;
+      flpp = &import_files;
+      while (*flpp != NULL)
+       flpp = &(*flpp)->next;
+      *flpp = n;
+
+      ret = true;
+      entry->loaded = true;
+    }
+
+  fclose (e);
+
+  return ret;
+}
+
 /* This is called after the input files have been opened.  */
 
 static void
@@ -406,9 +446,11 @@ gldppcmacos_after_open ()
   /* Call ldctor_build_sets, after pretending that this is a
      relocateable link.  We do this because AIX requires relocation
      entries for all references to symbols, even in a final
-     executable.  */
+     executable.  Of course, we only want to do this if we are
+     producing an XCOFF output file.  */
   r = link_info.relocateable;
-  link_info.relocateable = true;
+  if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL)
+    link_info.relocateable = true;
   ldctor_build_sets ();
   link_info.relocateable = r;
 
@@ -433,7 +475,7 @@ gldppcmacos_after_open ()
 
       size = (p->count + 2) * 4;
       if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size))
-       einfo ("%F%P: bfd_xcoff_link_record_set failed: %E\n");
+       einfo (_("%F%P: bfd_xcoff_link_record_set failed: %E\n"));
     }
 }
 
@@ -446,7 +488,6 @@ gldppcmacos_before_allocation ()
   struct filelist *fl;
   struct export_symbol_list *el;
   char *libpath;
-  boolean export_defineds;
   asection *special_sections[6];
   int i;
 
@@ -459,9 +500,9 @@ gldppcmacos_before_allocation ()
 
       h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false);
       if (h == NULL)
-       einfo ("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n");
+       einfo (_("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n"));
       if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall))
-       einfo ("%P%F: bfd_xcoff_export_symbol failed: %E\n");
+       einfo (_("%P%F: bfd_xcoff_export_symbol failed: %E\n"));
     }
 
   /* Track down all relocations called for by the linker script (these
@@ -497,12 +538,6 @@ gldppcmacos_before_allocation ()
        }
     }
 
-  /* If we are emulating the Unix linker, we want to export all
-     defined symbols, unless an explicit -bE option was used.  */
-  export_defineds = false;
-  if (unix_ld && export_symbols == NULL)
-    export_defineds = true;
-
   /* Let the XCOFF backend set up the .loader section.  */
   if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath,
                                         entry_symbol, file_align,
@@ -510,9 +545,9 @@ gldppcmacos_before_allocation ()
                                         gc && ! unix_ld ? true : false,
                                         modtype,
                                         textro ? true : false,
-                                        export_defineds,
+                                        unix_ld,
                                         special_sections))
-    einfo ("%P%F: failed to set dynamic section sizes: %E\n");
+    einfo (_("%P%F: failed to set dynamic section sizes: %E\n"));
 
   /* Look through the special sections, and put them in the right
      place in the link ordering.  This is especially magic.  */
@@ -534,15 +569,15 @@ gldppcmacos_before_allocation ()
       is = NULL;
       os = lang_output_section_find (sec->output_section->name);
       if (os == NULL)
-       einfo ("%P%F: can't find output section %s\n",
+       einfo (_("%P%F: can't find output section %s\n"),
               sec->output_section->name);
-      for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->next)
+      for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->header.next)
        {
          if ((*pls)->header.type == lang_input_section_enum
              && (*pls)->input_section.section == sec)
            {
              is = (lang_input_section_type *) *pls;
-             *pls = (*pls)->next;
+             *pls = (*pls)->header.next;
              break;
            }
          if ((*pls)->header.type == lang_wild_statement_enum)
@@ -551,13 +586,13 @@ gldppcmacos_before_allocation ()
 
              for (pwls = &(*pls)->wild_statement.children.head;
                   *pwls != NULL;
-                  pwls = &(*pwls)->next)
+                  pwls = &(*pwls)->header.next)
                {
                  if ((*pwls)->header.type == lang_input_section_enum
                      && (*pwls)->input_section.section == sec)
                    {
                      is = (lang_input_section_type *) *pwls;
-                     *pwls = (*pwls)->next;
+                     *pwls = (*pwls)->header.next;
                      break;
                    }
                }
@@ -567,7 +602,7 @@ gldppcmacos_before_allocation ()
        }       
 
       if (is == NULL)
-       einfo ("%P%F: can't find %s in output section\n",
+       einfo (_("%P%F: can't find %s in output section\n"),
               bfd_get_section_name (sec->owner, sec));
 
       /* Now figure out where the section should go.  */
@@ -640,7 +675,7 @@ gldppcmacos_read_file (filename, import)
   o = (struct obstack *) xmalloc (sizeof (struct obstack));
   obstack_specify_allocation (o, 0, 0, xmalloc, gldppcmacos_free);
 
-  f = fopen (filename, "r");
+  f = fopen (filename, FOPEN_RT);
   if (f == NULL)
     {
       bfd_set_error (bfd_error_system_call);
@@ -672,7 +707,7 @@ gldppcmacos_read_file (filename, import)
       ++lineno;
 
       s = (char *) obstack_base (o);
-      while (isspace ((unsigned char) *s))
+      while (ISSPACE (*s))
        ++s;
       if (*s == '\0'
          || *s == '*'
@@ -686,7 +721,7 @@ gldppcmacos_read_file (filename, import)
       if (*s == '#' && s[1] == '!')
        {
          s += 2;
-         while (isspace ((unsigned char) *s))
+         while (ISSPACE (*s))
            ++s;
          if (*s == '\0')
            {
@@ -696,7 +731,7 @@ gldppcmacos_read_file (filename, import)
              obstack_free (o, obstack_base (o));
            }
          else if (*s == '(')
-           einfo ("%F%s%d: #! ([member]) is not supported in import files",
+           einfo (_("%F%s%d: #! ([member]) is not supported in import files\n"),
                   filename, lineno);
          else
            {
@@ -706,8 +741,8 @@ gldppcmacos_read_file (filename, import)
              (void) obstack_finish (o);
              keep = true;
              imppath = s;
-             impfile = NULL;
-             while (! isspace ((unsigned char) *s) && *s != '(' && *s != '\0')
+             file = NULL;
+             while (! ISSPACE (*s) && *s != '(' && *s != '\0')
                {
                  if (*s == '/')
                    file = s + 1;
@@ -727,7 +762,7 @@ gldppcmacos_read_file (filename, import)
                }
              cs = *s;
              *s = '\0';
-             while (isspace ((unsigned char) cs))
+             while (ISSPACE (cs))
                {
                  ++s;
                  cs = *s;
@@ -736,7 +771,7 @@ gldppcmacos_read_file (filename, import)
                {
                  impmember = "";
                  if (cs != '\0')
-                   einfo ("%s:%d: warning: syntax error in import file\n",
+                   einfo (_("%s:%d: warning: syntax error in import file\n"),
                           filename, lineno);
                }
              else
@@ -748,7 +783,7 @@ gldppcmacos_read_file (filename, import)
                  if (*s == ')')
                    *s = '\0';
                  else
-                   einfo ("%s:%d: warning: syntax error in import file\n",
+                   einfo (_("%s:%d: warning: syntax error in import file\n"),
                           filename, lineno);
                }
            }
@@ -761,7 +796,7 @@ gldppcmacos_read_file (filename, import)
       syscall = false;
       address = (bfd_vma) -1;
 
-      while (! isspace ((unsigned char) *s) && *s != '\0')
+      while (! ISSPACE (*s) && *s != '\0')
        ++s;
       if (*s != '\0')
        {
@@ -769,19 +804,19 @@ gldppcmacos_read_file (filename, import)
 
          *s++ = '\0';
 
-         while (isspace ((unsigned char) *s))
+         while (ISSPACE (*s))
            ++s;
 
          se = s;
-         while (! isspace ((unsigned char) *se) && *se != '\0')
+         while (! ISSPACE (*se) && *se != '\0')
            ++se;
          if (*se != '\0')
            {
              *se++ = '\0';
-             while (isspace ((unsigned char) *se))
+             while (ISSPACE (*se))
                ++se;
              if (*se != '\0')
-               einfo ("%s%d: warning: syntax error in import/export file\n",
+               einfo (_("%s%d: warning: syntax error in import/export file\n"),
                       filename, lineno);
            }
 
@@ -794,7 +829,7 @@ gldppcmacos_read_file (filename, import)
 
              address = strtoul (s, &end, 0);
              if (*end != '\0')
-               einfo ("%s:%d: warning: syntax error in import/export file\n",
+               einfo (_("%s:%d: warning: syntax error in import/export file\n"),
                       filename, lineno);
            }
        }
@@ -807,7 +842,7 @@ gldppcmacos_read_file (filename, import)
          n = ((struct export_symbol_list *)
               xmalloc (sizeof (struct export_symbol_list)));
          n->next = export_symbols;
-         n->name = buystring (symname);
+         n->name = xstrdup (symname);
          n->syscall = syscall;
          export_symbols = n;
        }
@@ -825,7 +860,7 @@ gldppcmacos_read_file (filename, import)
              if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h,
                                             address, imppath, impfile,
                                             impmember))
-               einfo ("%X%s:%d: failed to import symbol %s: %E\n",
+               einfo (_("%X%s:%d: failed to import symbol %s: %E\n"),
                       filename, lineno, symname);
            }
        }
@@ -835,7 +870,7 @@ gldppcmacos_read_file (filename, import)
 
   if (obstack_object_size (o) > 0)
     {
-      einfo ("%s:%d: warning: ignoring unterminated last line\n",
+      einfo (_("%s:%d: warning: ignoring unterminated last line\n"),
             filename, lineno);
       obstack_free (o, obstack_base (o));
     }
@@ -870,9 +905,9 @@ gldppcmacos_find_relocs (s)
 
       rs = &s->reloc_statement;
       if (rs->name == NULL)
-       einfo ("%F%P: only relocations against symbols are permitted\n");
+       einfo (_("%F%P: only relocations against symbols are permitted\n"));
       if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name))
-       einfo ("%F%P: bfd_xcoff_link_count_reloc failed: %E\n");
+       einfo (_("%F%P: bfd_xcoff_link_count_reloc failed: %E\n"));
     }
 
   if (s->header.type == lang_assignment_statement_enum)
@@ -900,7 +935,7 @@ gldppcmacos_find_exp_assignment (exp)
        {
          if (! bfd_xcoff_record_link_assignment (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);
        }
       gldppcmacos_find_exp_assignment (exp->assign.src);
@@ -1185,4 +1220,5 @@ struct ld_emulation_xfer_struct ld_ppcmacos_emulation =
   0,   /* place_orphan */
   0,   /* set_symbols */
   gldppcmacos_parse_args,
+  gldppcmacos_unrecognized_file
 };