This is the mail archive of the
mailing list for the elfutils project.
Re: [PATCH] libdwfl: Special case linux-gate/vdso.so in core_file_read_eagerly.
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 19 Mar 2015 17:09:31 +0100
- Subject: Re: [PATCH] libdwfl: Special case linux-gate/vdso.so in core_file_read_eagerly.
On Wed, 2015-03-18 at 13:42 -0700, Roland McGrath wrote:
> Special-casing by name is obviously wrong. Can you characterize the case
> you're trying to address more precisely?
It is obviously wrong, but sadly the only thing that I believe we have
to go on. The case this is trying to fix is when the linux-gate/vdso is
dumped into the core file but not used anyway because it contains a
build-id. The current code assumes that when we have a build-id we will
always be able to find it on disk. That is in general better since it
might be that what got dumped into the core file might be incomplete,
might not contain shdrs, etc. And if we have a build-id we usually have
a good way to find the actual full ELF file on disk. But that isn't the
case for linux-gate/vdso since a) it is small and fits in one page and
b) often there isn't a real way to find a file image even by build-id.
O. Now that I have written that down. I see a better heuristic. We
actually know the size the whole ELF image must be... hack, hack...
Yep, that works too!
So how does that alternative patch look?
From 075361644f05005a9ad8034410a2f66cabd34219 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <email@example.com>
Date: Mon, 16 Mar 2015 16:52:04 +0100
Subject: [PATCH] libdwfl: Special case core_file_read_eagerly for small ELF
Small ELF images, like linux-gate or linux-vdso, might be available in the
core file, but not on disk, even if we have a build-id. If the whole image
is small enough try to read them in from the core file to make sure symbols
and unwind information are always available for them. We would already map
them in if the core file was opened with ELF_C_READ_MMAP.
Signed-off-by: Mark Wielaard <firstname.lastname@example.org>
libdwfl/ChangeLog | 4 ++++
libdwfl/core-file.c | 7 ++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index d40dbae..2cb74a4 100644
@@ -1,3 +1,7 @@
+2015-03-16 Mark Wielaard <email@example.com>
+ * core-file.c (core_file_read_eagerly): Special case small images.
2015-01-26 Mark Wielaard <firstname.lastname@example.org>
* dwfl_module_getdwarf.c (find_symtab): Explicitly clear symdata,
diff --git a/libdwfl/core-file.c b/libdwfl/core-file.c
index 50031ae..30a1f45 100644
@@ -1,5 +1,5 @@
/* Core file handling.
- Copyright (C) 2008-2010, 2013 Red Hat, Inc.
+ Copyright (C) 2008-2010, 2013, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -212,10 +212,11 @@ core_file_read_eagerly (Dwfl_Module *mod,
requires find_elf hook re-doing the magic to fall back if no file found
- if (mod->build_id_len > 0)
+ if (mod->build_id_len > 0 && whole > MAX_EAGER_COST)
/* There is a build ID that could help us find the whole file,
which might be more useful than what we have.
- We'll just rely on that. */
+ We'll just rely on that. Except if the image is small enough
+ to be complete read in from the core file. */
if (core->map_address != NULL)