+/* Create and initialize a BFD handle from a target in-memory range. */
+
+gdb_bfd_ref_ptr gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
+ const char *target,
+ const char *filename = nullptr);
+
+/* Range adapter for a BFD's sections.
+
+ To be used as:
+
+ for (asection *sect : gdb_bfd_all_sections (bfd))
+ ... use SECT ...
+ */
+
+using gdb_bfd_section_range = next_range<asection>;
+
+static inline gdb_bfd_section_range
+gdb_bfd_sections (bfd *abfd)
+{
+ return gdb_bfd_section_range (abfd->sections);
+}
+
+static inline gdb_bfd_section_range
+gdb_bfd_sections (const gdb_bfd_ref_ptr &abfd)
+{
+ return gdb_bfd_section_range (abfd->sections);
+};
+
+/* 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. */
+
+extern std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
+