PowerPC fix for ifunc broken by d1eca1e4
[deliverable/binutils-gdb.git] / bfd / archive.c
index 4b6a81cb0f998443098ed77036f09cfdf32eb9df..40a3395ba09be7cd60bc0220efa7b2ebe563e246 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for archive files (libraries).
-   Copyright 1990-2013 Free Software Foundation, Inc.
+   Copyright (C) 1990-2014 Free Software Foundation, Inc.
    Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -140,6 +140,7 @@ SUBSECTION
 #include "safe-ctype.h"
 #include "hashtab.h"
 #include "filenames.h"
+#include "bfdlink.h"
 
 #ifndef errno
 extern int errno;
@@ -379,6 +380,13 @@ _bfd_find_nested_archive (bfd *arch_bfd, const char *filename)
   bfd *abfd;
   const char *target;
 
+  /* PR 15140: Don't allow a nested archive pointing to itself.  */
+  if (filename_cmp (filename, arch_bfd->filename) == 0)
+    {
+      bfd_set_error (bfd_error_malformed_archive);
+      return NULL;
+    }
+
   for (abfd = arch_bfd->nested_archives;
        abfd != NULL;
        abfd = abfd->archive_next)
@@ -617,7 +625,6 @@ _bfd_append_relative_path (bfd *arch, char *elt_name)
 bfd *
 _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
 {
-  static file_ptr prev_filepos;
   struct areltdata *new_areldata;
   bfd *n_nfd;
   char *filename;
@@ -625,12 +632,6 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
   n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
   if (n_nfd)
     return n_nfd;
-  /* PR15140: Prevent an inifnite recursion scanning a malformed nested archive.  */
-  if (filepos == prev_filepos)
-    {
-      bfd_set_error (bfd_error_malformed_archive);
-      return NULL;
-    }
 
   if (0 > bfd_seek (archive, filepos, SEEK_SET))
     return NULL;
@@ -639,7 +640,6 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
     return NULL;
 
   filename = new_areldata->filename;
-  prev_filepos = filepos;
 
   if (bfd_is_thin_archive (archive))
     {
@@ -706,7 +706,7 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
   else
     {
       n_nfd->origin = n_nfd->proxy_origin;
-      n_nfd->filename = filename;
+      n_nfd->filename = xstrdup (filename);
     }
 
   n_nfd->arelt_data = new_areldata;
@@ -2357,6 +2357,10 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
                          map = new_map;
                        }
 
+                     if (strcmp (syms[src_count]->name, "__gnu_lto_slim") == 0)
+                       (*_bfd_error_handler)
+                         (_("%s: plugin needed to handle lto object"),
+                          bfd_get_filename (current));
                      namelen = strlen (syms[src_count]->name);
                      amt = sizeof (char *);
                      map[orl_count].name = (char **) bfd_alloc (arch, amt);
@@ -2733,7 +2737,7 @@ _bfd_archive_close_and_cleanup (bfd *abfd)
          bfd_ardata (abfd)->cache = NULL;
        }
     }
-  else if (arch_eltdata (abfd) != NULL)
+  if (arch_eltdata (abfd) != NULL)
     {
       struct areltdata *ared = arch_eltdata (abfd);
       htab_t htab = (htab_t) ared->parent_cache;
@@ -2752,5 +2756,8 @@ _bfd_archive_close_and_cleanup (bfd *abfd)
            }
        }
     }
+  if (abfd->is_linker_output)
+    (*abfd->link.hash->hash_table_free) (abfd);
+
   return TRUE;
 }
This page took 0.024951 seconds and 4 git commands to generate.