#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,
va_start (args, format);
printf ("bfd plugin: ");
vprintf (format, args);
+ putchar ('\n');
va_end (args);
return LDPS_OK;
}
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;
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)
{
return 0;
}
-static bfd_boolean
-bfd_plugin_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
-{
- BFD_ASSERT (0);
- return 0;
-}
-
const bfd_target plugin_vec =
{
"plugin", /* Name. */
},
{ /* bfd_set_format. */
bfd_false,
- bfd_plugin_mkobject,
+ bfd_false,
_bfd_generic_mkarchive,
bfd_false,
},