From 32a9e03835369b40c4341d7ead5842ffaab563fe Mon Sep 17 00:00:00 2001 From: Dragan Mladjenovic Date: Tue, 28 Feb 2017 14:37:57 +0100 Subject: [MIPS]: Relax dwarf section loading to accept both PROGBITS and MIPS_DWARF section types Change-Id: I0862d930d92687dee47daa8d4dc3a21524c1c893 Reviewed-on: https://chromium-review.googlesource.com/447697 Reviewed-by: Joshua Peraza --- src/common/linux/dump_symbols.cc | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/common/linux/dump_symbols.cc') diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index 40b9e478..5ef766fa 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -618,8 +618,6 @@ bool LoadSymbols(const string& obj_file, module->SetLoadAddress(loading_addr); info->set_loading_addr(loading_addr, obj_file); - Word debug_section_type = - elf_header->e_machine == EM_MIPS ? SHT_MIPS_DWARF : SHT_PROGBITS; const Shdr* sections = GetOffset(elf_header, elf_header->e_shoff); const Shdr* section_names = sections + elf_header->e_shstrndx; @@ -675,9 +673,19 @@ bool LoadSymbols(const string& obj_file, // Look for DWARF debugging information, and load it if present. const Shdr* dwarf_section = - FindElfSectionByName(".debug_info", debug_section_type, + FindElfSectionByName(".debug_info", SHT_PROGBITS, sections, names, names_end, elf_header->e_shnum); + + // .debug_info section type is SHT_PROGBITS for mips on pnacl toolchains, + // but MIPS_DWARF for regular gnu toolchains, so both need to be checked + if (elf_header->e_machine == EM_MIPS && !dwarf_section) { + dwarf_section = + FindElfSectionByName(".debug_info", SHT_MIPS_DWARF, + sections, names, names_end, + elf_header->e_shnum); + } + if (dwarf_section) { found_debug_info_section = true; found_usable_info = true; @@ -752,9 +760,19 @@ bool LoadSymbols(const string& obj_file, // Dwarf Call Frame Information (CFI) is actually independent from // the other DWARF debugging information, and can be used alone. const Shdr* dwarf_cfi_section = - FindElfSectionByName(".debug_frame", debug_section_type, + FindElfSectionByName(".debug_frame", SHT_PROGBITS, sections, names, names_end, elf_header->e_shnum); + + // .debug_frame section type is SHT_PROGBITS for mips on pnacl toolchains, + // but MIPS_DWARF for regular gnu toolchains, so both need to be checked + if (elf_header->e_machine == EM_MIPS && !dwarf_cfi_section) { + dwarf_cfi_section = + FindElfSectionByName(".debug_frame", SHT_MIPS_DWARF, + sections, names, names_end, + elf_header->e_shnum); + } + if (dwarf_cfi_section) { // Ignore the return value of this function; even without call frame // information, the other debugging information could be perfectly -- cgit v1.2.1