From 3ba809deb6c4c5159aaa2aa06a0e49a89d785aca Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sun, 29 Apr 2012 11:35:37 +0000 Subject: [PATCH] Correctly parse DW_FORM_ref_addr -- its format is different in Dwarf2 vs Dwarf3 and later. Fixes #298864. (Tom Tromey, tromey@redhat.com) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12545 --- coregrind/m_debuginfo/readdwarf3.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 4f789b1cec..8775e0b301 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -1121,9 +1121,17 @@ void get_Form_contents ( /*OUT*/ULong* cts, So for the moment we merely range-check, to see that they actually do specify a plausible offset within this object's .debug_info, and return the value unchanged. + + In DWARF 2, DW_FORM_ref_addr is address-sized, but in + DWARF 3 and later, it is offset-sized. */ - *cts = (ULong)(UWord)get_UWord(c); - *ctsSzB = sizeof(UWord); + if (cc->version == 2) { + *cts = (ULong)(UWord)get_UWord(c); + *ctsSzB = sizeof(UWord); + } else { + *cts = get_Dwarfish_UWord(c, cc->is_dw64); + *ctsSzB = cc->is_dw64 ? sizeof(ULong) : sizeof(UInt); + } TRACE_D3("0x%lx", (UWord)*cts); if (0) VG_(printf)("DW_FORM_ref_addr 0x%lx\n", (UWord)*cts); if (/* the following 2 are surely impossible, but ... */ -- 2.47.2