Add support to the MSP430 linker for the automatic placement of code and data into...
[deliverable/binutils-gdb.git] / ld / emultempl / aix.em
index b43ffbb36ee810ae913f420ebb078fcbb8e1c2fb..463cf17955b93e17627630a841a781960e249bb6 100644 (file)
@@ -9,9 +9,7 @@ fragment <<EOF
 /* This file is is generated by a shell script.  DO NOT EDIT! */
 
 /* AIX emulation code for ${EMULATION_NAME}
-   Copyright 1991, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008
-   Free Software Foundation, Inc.
+   Copyright (C) 1991-2015 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    AIX support by Ian Lance Taylor <ian@cygnus.com>
    AIX 64 bit support by Tom Rix <trix@redhat.com>
@@ -145,7 +143,7 @@ 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;
 
   /* The link_info.[init|fini]_functions are initialized in ld/lexsup.c.
@@ -216,6 +214,7 @@ gld${EMULATION_NAME}_add_options
     {"bexpall", no_argument, NULL, OPTION_EXPALL},
     {"bexpfull", no_argument, NULL, OPTION_EXPFULL},
     {"bexport", required_argument, NULL, OPTION_EXPORT},
+    {"bbigtoc", no_argument, NULL, OPTION_IGNORE},
     {"bf", no_argument, NULL, OPTION_ERNOTOK},
     {"bgc", no_argument, &gc, 1},
     {"bh", required_argument, NULL, OPTION_IGNORE},
@@ -258,7 +257,7 @@ gld${EMULATION_NAME}_add_options
     {NULL, no_argument, NULL, 0}
   };
 
-  /* Options supported by the AIX linker which we do not support: -f,
+  /* Options supported by the AIX linker which we do not support:
      -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps,
      -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl,
      -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl,
@@ -302,6 +301,76 @@ gld${EMULATION_NAME}_parse_args (int argc, char **argv)
   return FALSE;
 }
 
+/* Helper for option '-f', which specify a list of input files.
+   Contrary to the native linker, we don't support shell patterns
+   (simply because glob isn't always available).  */
+
+static void
+read_file_list (const char *filename)
+{
+  FILE *f;
+  /* An upper bound on the number of characters in the file.  */
+  long pos;
+  /* File in memory.  */
+  char *buffer;
+  size_t len;
+  char *b;
+  char *e;
+
+  f = fopen (filename, FOPEN_RT);
+  if (f == NULL)
+    {
+      einfo ("%F%P: cannot open %s\n", filename);
+      return;
+    }
+  if (fseek (f, 0L, SEEK_END) == -1)
+    goto error;
+  pos = ftell (f);
+  if (pos == -1)
+    goto error;
+  if (fseek (f, 0L, SEEK_SET) == -1)
+    goto error;
+
+  buffer = (char *) xmalloc (pos + 1);
+  len = fread (buffer, sizeof (char), pos, f);
+  if (len != (size_t) pos && ferror (f))
+    goto error;
+  /* Add a NUL terminator.  */
+  buffer[len] = '\0';
+  fclose (f);
+
+  /* Parse files.  */
+  b = buffer;
+  while (1)
+    {
+      /* Skip empty lines.  */
+      while (*b == '\n' || *b == '\r')
+        b++;
+
+      /* Stop if end of buffer.  */
+      if (b == buffer + len)
+        break;
+
+      /* Eat any byte until end of line.  */
+      for (e = b; *e != '\0'; e++)
+        if (*e == '\n' || *e == '\r')
+          break;
+
+      /* Replace end of line by nul.  */
+      if (*e != '\0')
+        *e++ = '\0';
+
+      if (b != e)
+        lang_add_input_file (b, lang_input_file_is_search_file_enum, NULL);
+      b = e;
+    }
+  return;
+
+ error:
+  einfo ("%F%P: cannot read %s\n", optarg);
+  fclose (f);
+}
+
 static bfd_boolean
 gld${EMULATION_NAME}_handle_option (int optc)
 {
@@ -317,6 +386,12 @@ gld${EMULATION_NAME}_handle_option (int optc)
       /* Long option which just sets a flag.  */
       break;
 
+    case 'f':
+      /* This overrides --auxiliary.  This option specifies a file containing
+         a list of input files.  */
+      read_file_list (optarg);
+      break;
+
     case 'D':
       val = bfd_scan_vma (optarg, &end, 0);
       if (*end != '\0')
@@ -592,7 +667,7 @@ gld${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry)
       *flpp = n;
 
       ret = TRUE;
-      entry->loaded = TRUE;
+      entry->flags.loaded = TRUE;
     }
 
   fclose (e);
@@ -608,6 +683,8 @@ gld${EMULATION_NAME}_after_open (void)
   bfd_boolean r;
   struct set_info *p;
 
+  after_open_default ();
+
   /* Call ldctor_build_sets, after pretending that this is a
      relocatable link.  We do this because AIX requires relocation
      entries for all references to symbols, even in a final
@@ -777,7 +854,7 @@ gld${EMULATION_NAME}_before_allocation (void)
       /* Remove this section from the list of the output section.
         This assumes we know what the script looks like.  */
       is = NULL;
-      os = lang_output_section_find (sec->output_section->name);
+      os = lang_output_section_get (sec->output_section);
       if (os == NULL)
        einfo ("%P%F: can't find output section %s\n",
               sec->output_section->name);
@@ -1031,6 +1108,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bfd_boolean import)
     {
       bfd_set_error (bfd_error_system_call);
       einfo ("%F%s: %E\n", filename);
+      return;
     }
 
   keep = FALSE;
@@ -1193,7 +1271,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bfd_boolean import)
            {
              struct export_symbol_list *n;
 
-             ldlang_add_undef (symname);
+             ldlang_add_undef (symname, TRUE);
              n = ((struct export_symbol_list *)
                   xmalloc (sizeof (struct export_symbol_list)));
              n->next = export_symbols;
@@ -1235,6 +1313,8 @@ gld${EMULATION_NAME}_read_file (const char *filename, bfd_boolean import)
       obstack_free (o, NULL);
       free (o);
     }
+
+  fclose (f);
 }
 
 /* This routine saves us from worrying about declaring free.  */
@@ -1319,7 +1399,7 @@ 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.
 
@@ -1424,14 +1504,18 @@ gld${EMULATION_NAME}_open_dynamic_archive (const char *arch,
                                           search_dirs_type *search,
                                           lang_input_statement_type *entry)
 {
-  const char *filename;
   char *path;
 
-  if (!entry->is_archive)
+  if (!entry->flags.maybe_archive)
     return FALSE;
 
-  filename = entry->filename;
-  path = concat (search->name, "/lib", entry->filename, arch, ".a", NULL);
+  if (entry->flags.full_name_provided)
+    path = concat (search->name, "/", entry->filename,
+                  (const char *) NULL);
+  else
+    path = concat (search->name, "/lib", entry->filename, arch, ".a",
+                  (const char *) NULL);
+
   if (!ldfile_try_open_bfd (path, entry))
     {
       free (path);
@@ -1469,6 +1553,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.025841 seconds and 4 git commands to generate.