Blame SOURCES/gdb-rhbz1842691-corefile-mem-access-8of15.patch

46818e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
46818e
From: Keith Seitz <keiths@redhat.com>
46818e
Date: Mon, 27 Jul 2020 18:51:07 -0400
46818e
Subject: gdb-rhbz1842691-corefile-mem-access-8of15.patch
46818e
46818e
;; Use NT_FILE note section for reading core target memory
46818e
;; Kevin Buettner, RH BZ 1842961
46818e
46818e
   Author: Kevin Buettner <kevinb@redhat.com>
46818e
   Date:   Thu Jun 11 19:20:03 2020 -0700
46818e
46818e
    Use NT_FILE note section for reading core target memory
46818e
46818e
    In his reviews of my v1 and v2 corefile related patches, Pedro
46818e
    identified two cases which weren't handled by those patches.
46818e
46818e
    In https://sourceware.org/pipermail/gdb-patches/2020-May/168826.html,
46818e
    Pedro showed that debugging a core file in which mmap() is used to
46818e
    create a new mapping over an existing file-backed mapping will
46818e
    produce incorrect results.  I.e, for his example, GDB would
46818e
    show:
46818e
46818e
    (gdb) disassemble main
46818e
    Dump of assembler code for function main:
46818e
       0x00000000004004e6 <+0>:	push   %rbp
46818e
       0x00000000004004e7 <+1>:	mov    %rsp,%rbp
46818e
    => 0x00000000004004ea <+4>:	callq  0x4003f0 <abort@plt>
46818e
    End of assembler dump.
46818e
46818e
    This sort of looks like it might be correct, but is not due to the
46818e
    fact that mmap(...MAP_FIXED...) was used to create a mapping (of all
46818e
    zeros) on top of the .text section.  So, the correct result should be:
46818e
46818e
    (gdb) disassemble main
46818e
    Dump of assembler code for function main:
46818e
       0x00000000004004e6 <+0>:	add    %al,(%rax)
46818e
       0x00000000004004e8 <+2>:	add    %al,(%rax)
46818e
    => 0x00000000004004ea <+4>:	add    %al,(%rax)
46818e
       0x00000000004004ec <+6>:	add    %al,(%rax)
46818e
       0x00000000004004ee <+8>:	add    %al,(%rax)
46818e
    End of assembler dump.
46818e
46818e
    The other case that Pedro found involved an attempted examination of a
46818e
    particular section in the test case from gdb.base/corefile.exp.  On
46818e
    Fedora 27 or 28, the following behavior may be observed:
46818e
46818e
    (gdb) info proc mappings
46818e
    Mapped address spaces:
46818e
46818e
              Start Addr           End Addr       Size     Offset objfile
46818e
    ...
46818e
          0x7ffff7839000     0x7ffff7a38000   0x1ff000   0x1b5000 /usr/lib64/libc-2.27.so
46818e
    ...
46818e
    (gdb) x/4x 0x7ffff7839000
46818e
    0x7ffff7839000:	Cannot access memory at address 0x7ffff7839000
46818e
46818e
    FYI, this section appears to be unrelocated vtable data.  See
46818e
    https://sourceware.org/pipermail/gdb-patches/2020-May/168331.html for
46818e
    a detailed analysis.
46818e
46818e
    The important thing here is that GDB should be able to access this
46818e
    address since it should be backed by the shared library.  I.e. it
46818e
    should do this:
46818e
46818e
    (gdb) x/4x 0x7ffff7839000
46818e
    0x7ffff7839000:	0x0007ddf0	0x00000000	0x0007dba0	0x00000000
46818e
46818e
    Both of these cases are fixed with this commit.
46818e
46818e
    In a nutshell, this commit opens a "binary" target BFD for each of the
46818e
    files that are mentioned in an NT_FILE / .note.linuxcore.file note
46818e
    section.  It then uses these mappings instead of the file stratum
46818e
    mappings that GDB has used in the past.
46818e
46818e
    If this note section doesn't exist or is mangled for some reason, then
46818e
    GDB will use the file stratum as before.  Should this happen, then
46818e
    we can expect both of the above problems to again be present.
46818e
46818e
    See the code comments in the commit for other details.
46818e
46818e
    gdb/ChangeLog:
46818e
46818e
    	* corelow.c (solist.h, unordered_map): Include.
46818e
    	(class core_target): Add field m_core_file_mappings and
46818e
    	method build_file_mappings.
46818e
    	(core_target::core_target): Call build_file_mappings.
46818e
    	(core_target::~core_target): Free memory associated with
46818e
    	m_core_file_mappings.
46818e
    	(core_target::build_file_mappings): New method.
46818e
    	(core_target::xfer_partial): Use m_core_file_mappings
46818e
    	for memory transfers.
46818e
    	* linux-tdep.c (linux_read_core_file_mappings): New
46818e
    	function.
46818e
    	(linux_core_info_proc_mappings): Rewrite to use
46818e
    	linux_read_core_file_mappings.
46818e
    	(linux_init_abi): Register linux_read_core_file_mappings.
46818e
46818e
diff --git a/gdb/corelow.c b/gdb/corelow.c
46818e
--- a/gdb/corelow.c
46818e
+++ b/gdb/corelow.c
46818e
@@ -41,6 +41,7 @@
46818e
 #include "exec.h"
46818e
 #include "readline/tilde.h"
46818e
 #include "solib.h"
46818e
+#include "solist.h"
46818e
 #include "filenames.h"
46818e
 #include "progspace.h"
46818e
 #include "objfiles.h"
46818e
@@ -48,6 +49,8 @@
46818e
 #include "completer.h"
46818e
 #include "gdbsupport/filestuff.h"
46818e
 #include "build-id.h"
46818e
+#include "gdbsupport/pathstuff.h"
46818e
+#include <unordered_map>
46818e
 
46818e
 #ifndef O_LARGEFILE
46818e
 #define O_LARGEFILE 0
46818e
@@ -132,6 +135,13 @@ private: /* per-core data */
46818e
      core file currently open on core_bfd.  */
46818e
   core_fns *m_core_vec = NULL;
46818e
 
46818e
+  /* File-backed address space mappings: some core files include
46818e
+     information about memory mapped files.  */
46818e
+  target_section_table m_core_file_mappings {};
46818e
+
46818e
+  /* Build m_core_file_mappings.  Called from the constructor.  */
46818e
+  void build_file_mappings ();
46818e
+
46818e
   /* FIXME: kettenis/20031023: Eventually this field should
46818e
      disappear.  */
46818e
   struct gdbarch *m_core_gdbarch = NULL;
46818e
@@ -150,11 +160,120 @@ core_target::core_target ()
46818e
 			   &m_core_section_table.sections_end))
46818e
     error (_("\"%s\": Can't find sections: %s"),
46818e
 	   bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ()));
46818e
+
46818e
+  build_file_mappings ();
46818e
 }
46818e
 
46818e
 core_target::~core_target ()
46818e
 {
46818e
   xfree (m_core_section_table.sections);
46818e
+  xfree (m_core_file_mappings.sections);
46818e
+}
46818e
+
46818e
+/* Construct the target_section_table for file-backed mappings if
46818e
+   they exist.
46818e
+
46818e
+   For each unique path in the note, we'll open a BFD with a bfd
46818e
+   target of "binary".  This is an unstructured bfd target upon which
46818e
+   we'll impose a structure from the mappings in the architecture-specific
46818e
+   mappings note.  A BFD section is allocated and initialized for each
46818e
+   file-backed mapping.
46818e
+
46818e
+   We take care to not share already open bfds with other parts of
46818e
+   GDB; in particular, we don't want to add new sections to existing
46818e
+   BFDs.  We do, however, ensure that the BFDs that we allocate here
46818e
+   will go away (be deallocated) when the core target is detached.  */
46818e
+
46818e
+void
46818e
+core_target::build_file_mappings ()
46818e
+{
46818e
+  std::unordered_map<std::string, struct bfd *> bfd_map;
46818e
+
46818e
+  /* See linux_read_core_file_mappings() in linux-tdep.c for an example
46818e
+     read_core_file_mappings method.  */
46818e
+  gdbarch_read_core_file_mappings (m_core_gdbarch, core_bfd,
46818e
+
46818e
+    /* After determining the number of mappings, read_core_file_mappings
46818e
+       will invoke this lambda which allocates target_section storage for
46818e
+       the mappings.  */
46818e
+    [&] (ULONGEST count)
46818e
+      {
46818e
+	m_core_file_mappings.sections = XNEWVEC (struct target_section, count);
46818e
+	m_core_file_mappings.sections_end = m_core_file_mappings.sections;
46818e
+      },
46818e
+
46818e
+    /* read_core_file_mappings will invoke this lambda for each mapping
46818e
+       that it finds.  */
46818e
+    [&] (int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs,
46818e
+         const char *filename, const void *other)
46818e
+      {
46818e
+	/* Architecture-specific read_core_mapping methods are expected to
46818e
+	   weed out non-file-backed mappings.  */
46818e
+	gdb_assert (filename != nullptr);
46818e
+
46818e
+	struct bfd *bfd = bfd_map[filename];
46818e
+	if (bfd == nullptr)
46818e
+	  {
46818e
+	    /* Use exec_file_find() to do sysroot expansion.  It'll
46818e
+	       also strip the potential sysroot "target:" prefix.  If
46818e
+	       there is no sysroot, an equivalent (possibly more
46818e
+	       canonical) pathname will be provided.  */
46818e
+	    gdb::unique_xmalloc_ptr<char> expanded_fname
46818e
+	      = exec_file_find (filename, NULL);
46818e
+	    if (expanded_fname == nullptr)
46818e
+	      {
46818e
+		warning (_("Can't open file %s during file-backed mapping "
46818e
+			   "note processing"),
46818e
+			 expanded_fname.get ());
46818e
+		return;
46818e
+	      }
46818e
+
46818e
+	    bfd = bfd_map[filename] = bfd_openr (expanded_fname.get (),
46818e
+	                                         "binary");
46818e
+
46818e
+	    if (bfd == nullptr || !bfd_check_format (bfd, bfd_object))
46818e
+	      {
46818e
+		/* If we get here, there's a good chance that it's due to
46818e
+		   an internal error.  We issue a warning instead of an
46818e
+		   internal error because of the possibility that the
46818e
+		   file was removed in between checking for its
46818e
+		   existence during the expansion in exec_file_find()
46818e
+		   and the calls to bfd_openr() / bfd_check_format(). 
46818e
+		   Output both the path from the core file note along
46818e
+		   with its expansion to make debugging this problem
46818e
+		   easier.  */
46818e
+		warning (_("Can't open file %s which was expanded to %s "
46818e
+			   "during file-backed mapping note processing"),
46818e
+			 filename, expanded_fname.get ());
46818e
+		if (bfd != nullptr)
46818e
+		  bfd_close (bfd);
46818e
+		return;
46818e
+	      }
46818e
+	    /* Ensure that the bfd will be closed when core_bfd is closed. 
46818e
+	       This can be checked before/after a core file detach via
46818e
+	       "maint info bfds".  */
46818e
+	    gdb_bfd_record_inclusion (core_bfd, bfd);
46818e
+	  }
46818e
+
46818e
+	/* Make new BFD section.  All sections have the same name,
46818e
+	   which is permitted by bfd_make_section_anyway().  */
46818e
+	asection *sec = bfd_make_section_anyway (bfd, "load");
46818e
+	if (sec == nullptr)
46818e
+	  error (_("Can't make section"));
46818e
+	sec->filepos = file_ofs;
46818e
+	bfd_set_section_flags (sec, SEC_READONLY | SEC_HAS_CONTENTS);
46818e
+	bfd_set_section_size (sec, end - start);
46818e
+	bfd_set_section_vma (sec, start);
46818e
+	bfd_set_section_lma (sec, start);
46818e
+	bfd_set_section_alignment (sec, 2);
46818e
+
46818e
+	/* Set target_section fields.  */
46818e
+	struct target_section *ts = m_core_file_mappings.sections_end++;
46818e
+	ts->addr = start;
46818e
+	ts->endaddr = end;
46818e
+	ts->owner = nullptr;
46818e
+	ts->the_bfd_section = sec;
46818e
+      });
46818e
 }
46818e
 
46818e
 /* List of all available core_fns.  On gdb startup, each core file
46818e
@@ -773,10 +892,21 @@ core_target::xfer_partial (enum target_object object, const char *annex,
46818e
 	if (xfer_status == TARGET_XFER_OK)
46818e
 	  return TARGET_XFER_OK;
46818e
 
46818e
-	/* Now check the stratum beneath us; this should be file_stratum.  */
46818e
-	xfer_status = this->beneath ()->xfer_partial (object, annex, readbuf,
46818e
-						      writebuf, offset, len,
46818e
-						      xfered_len);
46818e
+	/* Check file backed mappings.  If they're available, use
46818e
+	   core file provided mappings (e.g. from .note.linuxcore.file
46818e
+	   or the like) as this should provide a more accurate
46818e
+	   result.  If not, check the stratum beneath us, which should
46818e
+	   be the file stratum.  */
46818e
+	if (m_core_file_mappings.sections != nullptr)
46818e
+	  xfer_status = section_table_xfer_memory_partial
46818e
+			  (readbuf, writebuf,
46818e
+			   offset, len, xfered_len,
46818e
+			   m_core_file_mappings.sections,
46818e
+			   m_core_file_mappings.sections_end);
46818e
+	else
46818e
+	  xfer_status = this->beneath ()->xfer_partial (object, annex, readbuf,
46818e
+							writebuf, offset, len,
46818e
+							xfered_len);
46818e
 	if (xfer_status == TARGET_XFER_OK)
46818e
 	  return TARGET_XFER_OK;
46818e
 
46818e
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
46818e
--- a/gdb/linux-tdep.c
46818e
+++ b/gdb/linux-tdep.c
46818e
@@ -1024,106 +1024,174 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
46818e
     }
46818e
 }
46818e
 
46818e
-/* Implement "info proc mappings" for a corefile.  */
46818e
+/* Implementation of `gdbarch_read_core_file_mappings', as defined in
46818e
+   gdbarch.h.
46818e
+   
46818e
+   This function reads the NT_FILE note (which BFD turns into the
46818e
+   section ".note.linuxcore.file").  The format of this note / section
46818e
+   is described as follows in the Linux kernel sources in
46818e
+   fs/binfmt_elf.c:
46818e
+   
46818e
+      long count     -- how many files are mapped
46818e
+      long page_size -- units for file_ofs
46818e
+      array of [COUNT] elements of
46818e
+	long start
46818e
+	long end
46818e
+	long file_ofs
46818e
+      followed by COUNT filenames in ASCII: "FILE1" NUL "FILE2" NUL...
46818e
+      
46818e
+   CBFD is the BFD of the core file.
46818e
+
46818e
+   PRE_LOOP_CB is the callback function to invoke prior to starting
46818e
+   the loop which processes individual entries.  This callback will
46818e
+   only be executed after the note has been examined in enough
46818e
+   detail to verify that it's not malformed in some way.
46818e
+   
46818e
+   LOOP_CB is the callback function that will be executed once
46818e
+   for each mapping.  */
46818e
 
46818e
 static void
46818e
-linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
46818e
+linux_read_core_file_mappings (struct gdbarch *gdbarch,
46818e
+			       struct bfd *cbfd,
46818e
+			       gdb::function_view<void (ULONGEST count)>
46818e
+			         pre_loop_cb,
46818e
+			       gdb::function_view
46818e
+			                                ULONGEST start,
46818e
+							ULONGEST end,
46818e
+							ULONGEST file_ofs,
46818e
+							const char *filename,
46818e
+							const void *other)>
46818e
+				 loop_cb)
46818e
 {
46818e
-  asection *section;
46818e
-  ULONGEST count, page_size;
46818e
-  unsigned char *descdata, *filenames, *descend;
46818e
-  size_t note_size;
46818e
-  unsigned int addr_size_bits, addr_size;
46818e
-  struct gdbarch *core_gdbarch = gdbarch_from_bfd (core_bfd);
46818e
-  /* We assume this for reading 64-bit core files.  */
46818e
+  /* Ensure that ULONGEST is big enough for reading 64-bit core files.  */
46818e
   gdb_static_assert (sizeof (ULONGEST) >= 8);
46818e
 
46818e
-  section = bfd_get_section_by_name (core_bfd, ".note.linuxcore.file");
46818e
-  if (section == NULL)
46818e
-    {
46818e
-      warning (_("unable to find mappings in core file"));
46818e
-      return;
46818e
-    }
46818e
+  /* It's not required that the NT_FILE note exists, so return silently
46818e
+     if it's not found.  Beyond this point though, we'll complain
46818e
+     if problems are found.  */
46818e
+  asection *section = bfd_get_section_by_name (cbfd, ".note.linuxcore.file");
46818e
+  if (section == nullptr)
46818e
+    return;
46818e
 
46818e
-  addr_size_bits = gdbarch_addr_bit (core_gdbarch);
46818e
-  addr_size = addr_size_bits / 8;
46818e
-  note_size = bfd_section_size (section);
46818e
+  unsigned int addr_size_bits = gdbarch_addr_bit (gdbarch);
46818e
+  unsigned int addr_size = addr_size_bits / 8;
46818e
+  size_t note_size = bfd_section_size (section);
46818e
 
46818e
   if (note_size < 2 * addr_size)
46818e
-    error (_("malformed core note - too short for header"));
46818e
+    {
46818e
+      warning (_("malformed core note - too short for header"));
46818e
+      return;
46818e
+    }
46818e
 
46818e
-  gdb::def_vector<unsigned char> contents (note_size);
46818e
+  gdb::def_vector<gdb_byte> contents (note_size);
46818e
   if (!bfd_get_section_contents (core_bfd, section, contents.data (),
46818e
 				 0, note_size))
46818e
-    error (_("could not get core note contents"));
46818e
+    {
46818e
+      warning (_("could not get core note contents"));
46818e
+      return;
46818e
+    }
46818e
 
46818e
-  descdata = contents.data ();
46818e
-  descend = descdata + note_size;
46818e
+  gdb_byte *descdata = contents.data ();
46818e
+  char *descend = (char *) descdata + note_size;
46818e
 
46818e
   if (descdata[note_size - 1] != '\0')
46818e
-    error (_("malformed note - does not end with \\0"));
46818e
+    {
46818e
+      warning (_("malformed note - does not end with \\0"));
46818e
+      return;
46818e
+    }
46818e
 
46818e
-  count = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
+  ULONGEST count = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
   descdata += addr_size;
46818e
 
46818e
-  page_size = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
+  ULONGEST page_size = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
   descdata += addr_size;
46818e
 
46818e
   if (note_size < 2 * addr_size + count * 3 * addr_size)
46818e
-    error (_("malformed note - too short for supplied file count"));
46818e
-
46818e
-  printf_filtered (_("Mapped address spaces:\n\n"));
46818e
-  if (gdbarch_addr_bit (gdbarch) == 32)
46818e
-    {
46818e
-      printf_filtered ("\t%10s %10s %10s %10s %s\n",
46818e
-		       "Start Addr",
46818e
-		       "  End Addr",
46818e
-		       "      Size", "    Offset", "objfile");
46818e
-    }
46818e
-  else
46818e
     {
46818e
-      printf_filtered ("  %18s %18s %10s %10s %s\n",
46818e
-		       "Start Addr",
46818e
-		       "  End Addr",
46818e
-		       "      Size", "    Offset", "objfile");
46818e
+      warning (_("malformed note - too short for supplied file count"));
46818e
+      return;
46818e
     }
46818e
 
46818e
-  filenames = descdata + count * 3 * addr_size;
46818e
-  while (--count > 0)
46818e
+  char *filenames = (char *) descdata + count * 3 * addr_size;
46818e
+
46818e
+  /* Make sure that the correct number of filenames exist.  Complain
46818e
+     if there aren't enough or are too many.  */
46818e
+  char *f = filenames;
46818e
+  for (int i = 0; i < count; i++)
46818e
     {
46818e
-      ULONGEST start, end, file_ofs;
46818e
+      if (f >= descend)
46818e
+        {
46818e
+	  warning (_("malformed note - filename area is too small"));
46818e
+	  return;
46818e
+	}
46818e
+      f += strnlen (f, descend - f) + 1;
46818e
+    }
46818e
+  /* Complain, but don't return early if the filename area is too big.  */
46818e
+  if (f != descend)
46818e
+    warning (_("malformed note - filename area is too big"));
46818e
 
46818e
-      if (filenames == descend)
46818e
-	error (_("malformed note - filenames end too early"));
46818e
+  pre_loop_cb (count);
46818e
 
46818e
-      start = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
+  for (int i = 0; i < count; i++)
46818e
+    {
46818e
+      ULONGEST start = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
       descdata += addr_size;
46818e
-      end = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
+      ULONGEST end = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
       descdata += addr_size;
46818e
-      file_ofs = bfd_get (addr_size_bits, core_bfd, descdata);
46818e
+      ULONGEST file_ofs
46818e
+        = bfd_get (addr_size_bits, core_bfd, descdata) * page_size;
46818e
       descdata += addr_size;
46818e
+      char * filename = filenames;
46818e
+      filenames += strlen ((char *) filenames) + 1;
46818e
 
46818e
-      file_ofs *= page_size;
46818e
-
46818e
-      if (gdbarch_addr_bit (gdbarch) == 32)
46818e
-	printf_filtered ("\t%10s %10s %10s %10s %s\n",
46818e
-			 paddress (gdbarch, start),
46818e
-			 paddress (gdbarch, end),
46818e
-			 hex_string (end - start),
46818e
-			 hex_string (file_ofs),
46818e
-			 filenames);
46818e
-      else
46818e
-	printf_filtered ("  %18s %18s %10s %10s %s\n",
46818e
-			 paddress (gdbarch, start),
46818e
-			 paddress (gdbarch, end),
46818e
-			 hex_string (end - start),
46818e
-			 hex_string (file_ofs),
46818e
-			 filenames);
46818e
-
46818e
-      filenames += 1 + strlen ((char *) filenames);
46818e
+      loop_cb (i, start, end, file_ofs, filename, nullptr);
46818e
     }
46818e
 }
46818e
 
46818e
+/* Implement "info proc mappings" for a corefile.  */
46818e
+
46818e
+static void
46818e
+linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
46818e
+{
46818e
+  linux_read_core_file_mappings (gdbarch, core_bfd,
46818e
+    [=] (ULONGEST count)
46818e
+      {
46818e
+	printf_filtered (_("Mapped address spaces:\n\n"));
46818e
+	if (gdbarch_addr_bit (gdbarch) == 32)
46818e
+	  {
46818e
+	    printf_filtered ("\t%10s %10s %10s %10s %s\n",
46818e
+			     "Start Addr",
46818e
+			     "  End Addr",
46818e
+			     "      Size", "    Offset", "objfile");
46818e
+	  }
46818e
+	else
46818e
+	  {
46818e
+	    printf_filtered ("  %18s %18s %10s %10s %s\n",
46818e
+			     "Start Addr",
46818e
+			     "  End Addr",
46818e
+			     "      Size", "    Offset", "objfile");
46818e
+	  }
46818e
+      },
46818e
+    [=] (int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs,
46818e
+         const char *filename, const void *other)
46818e
+      {
46818e
+	if (gdbarch_addr_bit (gdbarch) == 32)
46818e
+	  printf_filtered ("\t%10s %10s %10s %10s %s\n",
46818e
+			   paddress (gdbarch, start),
46818e
+			   paddress (gdbarch, end),
46818e
+			   hex_string (end - start),
46818e
+			   hex_string (file_ofs),
46818e
+			   filename);
46818e
+	else
46818e
+	  printf_filtered ("  %18s %18s %10s %10s %s\n",
46818e
+			   paddress (gdbarch, start),
46818e
+			   paddress (gdbarch, end),
46818e
+			   hex_string (end - start),
46818e
+			   hex_string (file_ofs),
46818e
+			   filename);
46818e
+      });
46818e
+}
46818e
+
46818e
 /* Implement "info proc" for a corefile.  */
46818e
 
46818e
 static void
46818e
@@ -2471,6 +2539,7 @@ linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
46818e
   set_gdbarch_info_proc (gdbarch, linux_info_proc);
46818e
   set_gdbarch_core_info_proc (gdbarch, linux_core_info_proc);
46818e
   set_gdbarch_core_xfer_siginfo (gdbarch, linux_core_xfer_siginfo);
46818e
+  set_gdbarch_read_core_file_mappings (gdbarch, linux_read_core_file_mappings);
46818e
   set_gdbarch_find_memory_regions (gdbarch, linux_find_memory_regions);
46818e
   set_gdbarch_make_corefile_notes (gdbarch, linux_make_corefile_notes);
46818e
   set_gdbarch_has_shared_address_space (gdbarch,