if (abfd == nullptr)
return nullptr;
- if (!bfd_check_format (abfd, bfd_object)
- && !bfd_check_format (abfd, bfd_core))
+ if (!gdb_bfd_check_format (abfd, bfd_object)
+ && !gdb_bfd_check_format (abfd, bfd_core))
return NULL;
if (abfd->build_id != NULL)
styled_string (file_name_style.style (), filename),
bfd_errmsg (bfd_get_error ()));
- if (!bfd_check_format (ibfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (ibfd.get (), bfd_object))
error (_("'%ps' is not a recognized file format."),
styled_string (file_name_style.style (), filename));
styled_string (file_name_style.style (), filename.get ()),
bfd_errmsg (bfd_get_error ()));
- if (!bfd_check_format_matches (abfd.get (), bfd_object, &matching))
+ if (!gdb_bfd_check_format_matches (abfd.get (), bfd_object, &matching))
error (_("\"%ps\": not in loadable format: %s"),
styled_string (file_name_style.style (), filename.get ()),
gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
= gdb_bfd_open (expanded_fname.get (), gnutarget);
if (tmp_bfd != nullptr
- && bfd_check_format (tmp_bfd.get (), bfd_object)
+ && gdb_bfd_check_format (tmp_bfd.get (), bfd_object)
&& build_id_bfd_get (tmp_bfd.get ()) != nullptr)
{
/* The newly opened TMP_BFD has a build-id, and this mapped
if ((expanded_fname == nullptr
|| abfd == nullptr
- || !bfd_check_format (abfd.get (), bfd_object))
+ || !gdb_bfd_check_format (abfd.get (), bfd_object))
&& file_data.build_id != nullptr)
{
abfd = find_objfile_by_build_id (current_program_space,
if (expanded_fname == nullptr
|| abfd == nullptr
- || !bfd_check_format (abfd.get (), bfd_object))
+ || !gdb_bfd_check_format (abfd.get (), bfd_object))
{
/* If ABFD was opened, but the wrong format, close it now. */
abfd = nullptr;
if (temp_bfd == NULL)
perror_with_name (filename.c_str ());
- if (!bfd_check_format (temp_bfd.get (), bfd_core))
+ if (!gdb_bfd_check_format (temp_bfd.get (), bfd_core))
{
/* Do it after the err msg */
/* FIXME: should be checking for errors from bfd_close (for one
static bool
verify_id (bfd *abfd, size_t len, const bfd_byte *buildid, bool dwarf5)
{
- if (!bfd_check_format (abfd, bfd_object))
+ if (!gdb_bfd_check_format (abfd, bfd_object))
return false;
if (dwarf5)
static gdb::mutex mutex;
gdb::lock_guard<gdb::mutex> lock (mutex);
- if (!bfd_check_format (sym_bfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (sym_bfd.get (), bfd_object))
return NULL;
/* Success. Record the bfd as having been included by the objfile's bfd.
(make_unique_xstrdup (gdb_realpath_keepfile
(scratch_pathname).c_str ()));
- if (!bfd_check_format_matches (current_program_space->exec_bfd (),
+ if (!gdb_bfd_check_format_matches (current_program_space->exec_bfd (),
bfd_object, &matching))
{
/* Make sure to close exec_bfd, or else "run" might try to use
symbol_table.size () - 1);
}
+/* See gdb_bfd.h. */
+
+bool
+gdb_bfd_check_format (bfd *abfd, bfd_format format)
+{
+ return bfd_check_format (abfd, format);
+}
+
+/* See gdb_bfd.h. */
+
+bool
+gdb_bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
+{
+ return bfd_check_format_matches (abfd, format, matching);
+}
+
/* Implement the 'maint info bfd' command. */
static void
/* A wrapper for bfd_errmsg to produce a more helpful error message
in the case of bfd_error_file_ambiguously recognized.
MATCHING, if non-NULL, is the corresponding argument to
- bfd_check_format_matches, and will be freed. */
+ gdb_bfd_check_format_matches, and will be freed. */
extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
extern gdb::array_view<asymbol *> gdb_bfd_canonicalize_symtab
(bfd *abfd, bool should_throw = true);
+/* A wrapper for bfd_check_format. */
+
+extern bool gdb_bfd_check_format (bfd *abfd, bfd_format format);
+
+/* A wrapper for bfd_check_format_matches. */
+
+extern bool gdb_bfd_check_format_matches (bfd *abfd, bfd_format format,
+ char ***matching);
+
#endif /* GDB_GDB_BFD_H */
static enum gdb_osabi
i386_mach_o_osabi_sniffer (bfd *abfd)
{
- if (!bfd_check_format (abfd, bfd_object))
+ if (!gdb_bfd_check_format (abfd, bfd_object))
return GDB_OSABI_UNKNOWN;
if (bfd_get_arch (abfd) == bfd_arch_i386)
/* Check the format. NOTE: This initializes important data that GDB uses!
We would segfault later without this line. */
- if (!bfd_check_format (nbfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (nbfd.get (), bfd_object))
{
gdb_printf (gdb_stderr, _("\
JITed symbol file is not an object file, ignoring it.\n"));
macho_debug (0, _("Loading debugging symbols from oso: %s\n"), oso->name);
- if (!bfd_check_format (abfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (abfd.get (), bfd_object))
{
warning (_("`%s': can't read symbols: %s."), oso->name,
bfd_errmsg (bfd_get_error ()));
ix = last_ix;
continue;
}
- if (!bfd_check_format (archive_bfd.get (), bfd_archive))
+ if (!gdb_bfd_check_format (archive_bfd.get (), bfd_archive))
{
warning (_("OSO archive file \"%s\" not an archive."),
archive_name.c_str ());
return NULL;
}
- if (!bfd_check_format (dsym_bfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (dsym_bfd.get (), bfd_object))
{
warning (_("bad dsym file format: %s"), bfd_errmsg (bfd_get_error ()));
return NULL;
if (abfd == NULL)
return NULL;
- if (!bfd_check_format (abfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (abfd.get (), bfd_object))
{
warning (_("Cannot parse .gnu_debugdata section; not a BFD object"));
return NULL;
return NULL;
}
- if (bfd_check_format (archive_bfd.get (), bfd_object))
+ if (gdb_bfd_check_format (archive_bfd.get (), bfd_object))
return archive_bfd;
- if (! bfd_check_format (archive_bfd.get (), bfd_archive))
+ if (! gdb_bfd_check_format (archive_bfd.get (), bfd_archive))
{
warning (_("\"%ps\": not in executable format: %s."),
styled_string (file_name_style.style (), filename.c_str ()),
return NULL;
}
- if (! bfd_check_format (object_bfd.get (), bfd_object))
+ if (! gdb_bfd_check_format (object_bfd.get (), bfd_object))
{
warning (_("%ps(%s): not in object format: %s."),
styled_string (file_name_style.style (), filename.c_str ()),
bfd_errmsg (bfd_get_error ()));
/* Check bfd format. */
- if (!bfd_check_format (abfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (abfd.get (), bfd_object))
error (_("`%s': not in executable format: %s"),
bfd_get_filename (abfd.get ()), bfd_errmsg (bfd_get_error ()));
gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname.get (), found_file));
/* Check bfd format. */
- if (!bfd_check_format (abfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (abfd.get (), bfd_object))
error (_("`%ps': not in executable format: %s"),
styled_string (file_name_style.style (),
bfd_get_filename (abfd.get ())),
return {};
/* Check that ABFD is an ET_DYN ELF file. */
- if (!bfd_check_format (abfd.get (), bfd_object)
+ if (!gdb_bfd_check_format (abfd.get (), bfd_object)
|| !(bfd_get_file_flags (abfd.get ()) & DYNAMIC))
return {};
name = "shared object read from target memory";
bfd_set_filename (nbfd, name);
- if (!bfd_check_format (nbfd, bfd_object))
+ if (!gdb_bfd_check_format (nbfd, bfd_object))
error (_("Got object file from memory but can't read symbols: %s."),
bfd_errmsg (bfd_get_error ()));
styled_string (file_name_style.style (), name),
bfd_errmsg (bfd_get_error ()));
- if (!bfd_check_format (sym_bfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (sym_bfd.get (), bfd_object))
error (_("`%ps': can't read symbols: %s."),
styled_string (file_name_style.style (), name),
bfd_errmsg (bfd_get_error ()));
if (loadfile_bfd == NULL)
perror_with_name (filename.get ());
- if (!bfd_check_format (loadfile_bfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (loadfile_bfd.get (), bfd_object))
error (_("\"%ps\" is not an object file: %s"),
styled_string (file_name_style.style (), filename.get ()),
bfd_errmsg (bfd_get_error ()));
std::string original_name = objfile.original_name;
/* bfd_openr sets cacheable to true, which is what we want. */
- if (!bfd_check_format (objfile.obfd.get (), bfd_object))
+ if (!gdb_bfd_check_format (objfile.obfd.get (), bfd_object))
error (_("Can't read symbols from %ps: %s."),
styled_string (file_name_style.style (),
objfile_name (&objfile)),
if (abfd == NULL)
return so;
- if (bfd_check_format (abfd.get (), bfd_object))
+ if (gdb_bfd_check_format (abfd.get (), bfd_object))
text = bfd_get_section_by_name (abfd.get (), ".text");
if (!text)