]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix the computation of debuginfo bias values, in the case where the
authorJulian Seward <jseward@acm.org>
Tue, 7 Jun 2011 22:44:09 +0000 (22:44 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 7 Jun 2011 22:44:09 +0000 (22:44 +0000)
debuginfo object has been not been prelinked but the main object has.
Fixes a segfault observed running any C++ application (eg,
drd/tests/annotate_smart_pointer) on Fedora 14 (32-bit), when the
debuginfo RPM for libstdc++ is installed.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11801

coregrind/m_debuginfo/readelf.c

index e6849fdb58de49dea64ff4ec3136b355f17fa69f..29f4d3dfa3429d34fc38d4f8c1c85f8046b232ee 100644 (file)
@@ -2179,8 +2179,15 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
                                           shdr_strtab_dimg + shdr->sh_name)) { \
                      vg_assert(di->sec##_size == shdr->sh_size); \
                      vg_assert(di->sec##_avma +  shdr->sh_addr + seg##_dbias); \
+                     /* Assume we have a correct value for the main */ \
+                     /* object's bias.  Use that to derive the debuginfo */ \
+                     /* object's bias, by adding the difference in SVMAs */ \
+                     /* for the corresponding sections in the two files. */ \
+                     /* That should take care of all prelinking effects. */ \
                      di->sec##_debug_svma = shdr->sh_addr; \
-                     di->sec##_debug_bias = seg##_dbias; \
+                     di->sec##_debug_bias \
+                        = di->sec##_bias + \
+                          di->sec##_svma - di->sec##_debug_svma; \
                      TRACE_SYMTAB("acquiring ." #sec " debug svma = %#lx .. %#lx\n", \
                                   di->sec##_debug_svma, \
                                   di->sec##_debug_svma + di->sec##_size - 1); \