+2019-09-11 Tom Tromey <tom@tromey.com>
+
+ * opncls.c (bfd_set_filename): New function.
+ * bfd-in2.h: Regenerate.
+
2019-09-11 Alan Modra <amodra@gmail.com>
* targets.c (struct bfd_target): Add _bfd_group_name.
char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir);
+void bfd_set_filename (bfd *abfd, char *filename);
+
/* Extracted from libbfd.c. */
/* Byte swapping macros for user section data. */
get_build_id_name,
check_build_id_file, &build_id);
}
+
+/*
+FUNCTION
+ bfd_set_filename
+
+SYNOPSIS
+ void bfd_set_filename (bfd *abfd, char *filename);
+
+DESCRIPTION
+ Set the filename of @var{abfd}. The old filename, if any, is freed.
+ @var{filename} must be allocated using @code{xmalloc}. After
+ this call, it is owned @var{abfd}.
+*/
+
+void
+bfd_set_filename (bfd *abfd, char *filename)
+{
+ free ((char *) abfd->filename);
+ abfd->filename = filename;
+}
+2019-09-11 Tom Tromey <tom@tromey.com>
+
+ * symfile-mem.c (symbol_file_add_from_memory): Use
+ bfd_set_filename.
+ * solib-darwin.c (darwin_bfd_open): Use bfd_set_filename.
+ * solib-aix.c (solib_aix_bfd_open): Use bfd_set_filename.
+
2019-09-10 Tom Tromey <tromey@adacore.com>
* dwarf-index-write.c (write_psymbols): Extend error message.
along with appended parenthesized member name in order to allow commands
listing all shared libraries to display. Otherwise, we would only be
displaying the name of the archive member object. */
- xfree ((char *) bfd_get_filename (object_bfd.get ()));
- object_bfd->filename = xstrprintf ("%s%s",
- bfd_get_filename (archive_bfd.get ()),
- sep);
+ bfd_set_filename (object_bfd.get (),
+ xstrprintf ("%s%s",
+ bfd_get_filename (archive_bfd.get ()),
+ sep));
return object_bfd;
}
/* The current filename for fat-binary BFDs is a name generated
by BFD, usually a string containing the name of the architecture.
Reset its value to the actual filename. */
- xfree ((char *) bfd_get_filename (res.get ()));
- res->filename = xstrdup (pathname);
+ bfd_set_filename (res.get (), xstrdup (pathname));
return res;
}
/* Manage the new reference for the duration of this function. */
gdb_bfd_ref_ptr nbfd_holder = gdb_bfd_ref_ptr::new_reference (nbfd);
- xfree ((char *) bfd_get_filename (nbfd));
if (name == NULL)
- nbfd->filename = xstrdup ("shared object read from target memory");
- else
- nbfd->filename = name;
+ name = xstrdup ("shared object read from target memory");
+ bfd_set_filename (nbfd, name);
if (!bfd_check_format (nbfd, bfd_object))
error (_("Got object file from memory but can't read symbols: %s."),