daily update
[deliverable/binutils-gdb.git] / bfd / plugin.c
index 2874fa67a01592ee2cbfb455563115f8fdc77abb..dde61c883093cf43b8fda98994cdc0966c5b9dad 100644 (file)
@@ -68,6 +68,7 @@
 #define bfd_plugin_bfd_discard_group                  bfd_generic_discard_group
 #define bfd_plugin_section_already_linked             _bfd_generic_section_already_linked
 #define bfd_plugin_bfd_define_common_symbol           bfd_generic_define_common_symbol
+#define bfd_plugin_bfd_copy_link_hash_symbol_type     _bfd_generic_copy_link_hash_symbol_type
 
 static enum ld_plugin_status
 message (int level ATTRIBUTE_UNUSED,
@@ -77,6 +78,7 @@ message (int level ATTRIBUTE_UNUSED,
   va_start (args, format);
   printf ("bfd plugin: ");
   vprintf (format, args);
+  putchar ('\n');
   va_end (args);
   return LDPS_OK;
 }
@@ -230,30 +232,51 @@ static const bfd_target *
 bfd_plugin_object_p (bfd *abfd)
 {
   int claimed = 0;
-  int t = load_plugin ();
   struct ld_plugin_input_file file;
-  if (!t)
+  bfd *iobfd;
+  static int have_loaded = 0;
+  static int have_plugin = 0;
+
+  if (!have_loaded)
+    {
+      have_loaded = 1;
+      have_plugin = load_plugin ();
+    }
+  if (!have_plugin)
     return NULL;
 
   file.name = abfd->filename;
 
-  if (abfd->iostream)
+  if (abfd->my_archive)
     {
-      file.fd = fileno (abfd->iostream);
-      file.offset = 0;
-      file.filesize = 0; /*FIXME*/
+      iobfd = abfd->my_archive;
+      file.offset = abfd->origin;
+      file.filesize = arelt_size (abfd);
     }
   else
     {
-      bfd *archive = abfd->my_archive;
-      BFD_ASSERT (archive);
-      file.fd = fileno (archive->iostream);
-      file.offset = abfd->origin;
-      file.filesize = arelt_size (abfd);
+      iobfd = abfd;
+      file.offset = 0;
+      file.filesize = 0;
+    }
 
+  if (!iobfd->iostream && !bfd_open_file (iobfd))
+    return NULL;
+
+  file.fd = fileno ((FILE *) iobfd->iostream);
+
+  if (!abfd->my_archive)
+    {
+      struct stat stat_buf;
+      if (fstat (file.fd, &stat_buf))
+        return NULL;
+      file.filesize = stat_buf.st_size;
     }
+
   file.handle = abfd;
+  off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
   claim_file (&file, &claimed);
+  lseek(file.fd, cur_offset, SEEK_SET);
   if (!claimed)
     return NULL;
 
@@ -318,6 +341,13 @@ bfd_plugin_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
   return 0;
 }
 
+static int
+bfd_plugin_core_file_pid (bfd *abfd ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return 0;
+}
+
 static long
 bfd_plugin_get_symtab_upper_bound (bfd *abfd)
 {
@@ -434,13 +464,6 @@ bfd_plugin_sizeof_headers (bfd *a ATTRIBUTE_UNUSED,
   return 0;
 }
 
-static bfd_boolean
-bfd_plugin_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
-{
-  BFD_ASSERT (0);
-  return 0;
-}
-
 const bfd_target plugin_vec =
 {
   "plugin",                    /* Name.  */
@@ -471,7 +494,7 @@ const bfd_target plugin_vec =
   },
   {                            /* bfd_set_format.  */
     bfd_false,
-    bfd_plugin_mkobject,
+    bfd_false,
     _bfd_generic_mkarchive,
     bfd_false,
   },
This page took 0.029583 seconds and 4 git commands to generate.