ruby-changes:52880
From: naruse <ko1@a...>
Date: Tue, 16 Oct 2018 16:12:30 +0900 (JST)
Subject: [ruby-changes:52880] naruse:r65092 (trunk): check dwarf version and skip non Dwarf v4
naruse 2018-10-16 16:12:26 +0900 (Tue, 16 Oct 2018) New Revision: 65092 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65092 Log: check dwarf version and skip non Dwarf v4 Modified files: trunk/addr2line.c Index: addr2line.c =================================================================== --- addr2line.c (revision 65091) +++ addr2line.c (revision 65092) @@ -926,7 +926,7 @@ di_read_debug_line_cu(DebugInfoReader *r https://github.com/ruby/ruby/blob/trunk/addr2line.c#L926 } -static void +static int di_read_cu(DebugInfoReader *reader) { DW_CompilationUnitHeader32 *hdr32 = (DW_CompilationUnitHeader32 *)reader->p; @@ -937,16 +937,19 @@ di_read_cu(DebugInfoReader *reader) https://github.com/ruby/ruby/blob/trunk/addr2line.c#L937 reader->q0 = reader->obj->debug_abbrev.ptr + hdr->debug_abbrev_offset; reader->address_size = hdr->address_size; reader->format = 64; + if (hdr->version != 4) return -1; } else { DW_CompilationUnitHeader32 *hdr = hdr32; reader->p += 11; reader->q0 = reader->obj->debug_abbrev.ptr + hdr->debug_abbrev_offset; reader->address_size = hdr->address_size; reader->format = 32; + if (hdr->version != 4) return -1; } reader->level = 0; di_read_debug_abbrev_cu(reader); di_read_debug_line_cu(reader); + return 0; } static void @@ -1690,12 +1693,13 @@ fill_lines(int num_traces, void **traces https://github.com/ruby/ruby/blob/trunk/addr2line.c#L1693 i = 0; while (reader.p < reader.pend) { //fprintf(stderr, "%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info, i++); - di_read_cu(&reader); + if (di_read_cu(&reader)) goto use_symtab; debug_info_read(&reader, num_traces, traces, lines, offset); } } else { /* This file doesn't have dwarf, use symtab or dynsym */ + use_symtab: if (!symtab_shdr) { /* This file doesn't have symtab, use dynsym instead */ symtab_shdr = dynsym_shdr; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/