From: Julian Seward Date: Tue, 7 Jun 2011 22:44:09 +0000 (+0000) Subject: Fix the computation of debuginfo bias values, in the case where the X-Git-Tag: svn/VALGRIND_3_7_0~436 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9ce3d3cc83d9e919bc117e063a3cf576fc82e5c;p=thirdparty%2Fvalgrind.git Fix the computation of debuginfo bias values, in the case where the 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 --- diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index e6849fdb58..29f4d3dfa3 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -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); \