This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug in dwfl_module_addrsym


Hi,

I found a small bug in dwfl_module_addrsym. If no symbol with an actual
size was found for an address the sizeless_sym closest to the desired
address could be replaced with a sizeless_sym that was actually further
away. And so no sym would be returned at all. The attached patch fixes
it and adds a check to see if the whole same_section check and the
sizeless_sym update is even needed (it isn't if a full sized symbol has
already been found). Which gives a small speedup and turns up a couple
of extra symbols when inspecting vmlinux debuginfo with eu-readelf -w.

OK, to apply?

Thanks,

Mark
From f9c1da9fbbeda8d18eee901c136d9ea484fa9ee3 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Mon, 31 Oct 2011 15:33:49 +0100
Subject: [PATCH] dwfl_module_addrsym update sizeless_sym only if closer to
 desired addr.

---
 libdwfl/ChangeLog             |    5 +++++
 libdwfl/dwfl_module_addrsym.c |    4 +++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index adf3efa..97caf0b 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-31  Mark Wielaard  <mjw@redhat.com>
+
+	* dwfl_module_addrsym.c (dwfl_module_addrsym): Only update
+	sizeless_sym if needed and closer to desired addr.
+
 2011-10-20  Mark Wielaard  <mjw@redhat.com>
 
 	* derelocate.c (cache_sections): Intern mod->reloc_info check.
diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c
index a9f98f4..41ff465 100644
--- a/libdwfl/dwfl_module_addrsym.c
+++ b/libdwfl/dwfl_module_addrsym.c
@@ -138,7 +138,9 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr,
 		      closest_shndx = shndx;
 		      closest_name = name;
 		    }
-		  else if (same_section (&sym, shndx))
+		  else if (closest_name == NULL
+			   && sym.st_value >= min_label
+			   && same_section (&sym, shndx))
 		    {
 		      /* Handwritten assembly symbols sometimes have no
 			 st_size.  If no symbol with proper size includes
-- 
1.7.4.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]