+ gdb_printf ("Save segment, %s bytes at %s\n",
+ plongest (size), paddress (target_gdbarch (), vaddr));
+ }
+
+ bfd_set_section_size (osec, size);
+ bfd_set_section_vma (osec, vaddr);
+ bfd_set_section_lma (osec, 0);
+ return 0;
+}
+
+/* gdbarch_find_memory_region callback for creating a memory tag section.
+ DATA is 'bfd *' for the core file GDB is creating. */
+
+static int
+gcore_create_memtag_section_callback (CORE_ADDR vaddr, unsigned long size,
+ int read, int write, int exec,
+ int modified, bool memory_tagged,
+ void *data)
+{
+ /* Are there memory tags in this particular memory map entry? */
+ if (!memory_tagged)
+ return 0;
+
+ bfd *obfd = (bfd *) data;
+
+ /* Ask the architecture to create a memory tag section for this particular
+ memory map entry. It will be populated with contents later, as we can't
+ start writing the contents before we have all the sections sorted out. */
+ asection *memtag_section
+ = gdbarch_create_memtag_section (target_gdbarch (), obfd, vaddr, size);
+
+ if (memtag_section == nullptr)
+ {
+ warning (_("Couldn't make gcore memory tag segment: %s"),
+ bfd_errmsg (bfd_get_error ()));
+ return 1;
+ }
+
+ if (info_verbose)
+ {
+ gdb_printf (gdb_stdout, "Saved memory tag segment, %s bytes "
+ "at %s\n",
+ plongest (bfd_section_size (memtag_section)),
+ paddress (target_gdbarch (), vaddr));