From: Mark Wielaard Date: Thu, 11 Apr 2013 17:55:39 +0000 (+0000) Subject: read_unitinfo_dwarf2 DW_FORM_ref_addr is address size in DWARF version 2. X-Git-Tag: svn/VALGRIND_3_9_0~317 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d0adfcedccac8d3383cfbe8a5d670761764b1b6;p=thirdparty%2Fvalgrind.git read_unitinfo_dwarf2 DW_FORM_ref_addr is address size in DWARF version 2. Bug #305513 contained a patch for some extra robustness checks. But the real cause of crashing in the read_unitinfo_dwarf2 DWARF reader seemed to have been this issue where DWARF version 2 DWZ partial_units were read and DW_FORM_ref_addr had an unexpected size. This combination is rare. DWARF version 4 is the current default version of GCC. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13367 --- diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c index ce34bc767b..52a9099370 100644 --- a/coregrind/m_debuginfo/readdwarf.c +++ b/coregrind/m_debuginfo/readdwarf.c @@ -991,7 +991,7 @@ void read_unitinfo_dwarf2( /*OUT*/UnitInfo* ui, UInt acode, abcode; ULong atoffs, blklen; Int level; - /* UShort ver; */ + UShort ver; UChar addr_size; UChar* p = unitblock_img; @@ -1008,7 +1008,7 @@ void read_unitinfo_dwarf2( /*OUT*/UnitInfo* ui, p += ui->dw64 ? 12 : 4; /* version should be 2, 3 or 4 */ - /* ver = ML_(read_UShort)(p); */ + ver = ML_(read_UShort)(p); p += 2; /* get offset in abbrev */ @@ -1122,7 +1122,7 @@ void read_unitinfo_dwarf2( /*OUT*/UnitInfo* ui, case 0x0c: /* FORM_flag */ p++; break; case 0x0d: /* FORM_sdata */ read_leb128S( &p ); break; case 0x0f: /* FORM_udata */ read_leb128U( &p ); break; - case 0x10: /* FORM_ref_addr */ p += ui->dw64 ? 8 : 4; break; + case 0x10: /* FORM_ref_addr */ p += (ver == 2) ? addr_size : (ui->dw64 ? 8 : 4); break; case 0x11: /* FORM_ref1 */ p++; break; case 0x12: /* FORM_ref2 */ p += 2; break; case 0x13: /* FORM_ref4 */ p += 4; break;