pcc created this revision. pcc added a reviewer: labath. Herald added a subscriber: emaste. Herald added a reviewer: espindola. pcc requested review of this revision. Herald added a subscriber: MaskRay. Herald added a project: LLDB.
It is possible for the GetSectionHeaderByIndex lookup to fail because the previous FindSectionContainingFileAddress lookup found a segment instead of a section. This is possible if the binary does not have a PLT (which means that lld will in some circumstances set DT_JMPREL to 0, which is typically an address that is part of the ELF headers and not in a section) and may also be possible if the section headers have been stripped. To handle this possibility, replace the assert with an if. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D93438 Files: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2758,14 +2758,14 @@ user_id_t reloc_id = reloc_section->GetID(); const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id); - assert(reloc_header); + if (reloc_header) { + if (m_symtab_up == nullptr) + m_symtab_up = + std::make_unique<Symtab>(reloc_section->GetObjectFile()); - if (m_symtab_up == nullptr) - m_symtab_up = - std::make_unique<Symtab>(reloc_section->GetObjectFile()); - - ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header, - reloc_id); + ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header, + reloc_id); + } } }
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2758,14 +2758,14 @@ user_id_t reloc_id = reloc_section->GetID(); const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id); - assert(reloc_header); + if (reloc_header) { + if (m_symtab_up == nullptr) + m_symtab_up = + std::make_unique<Symtab>(reloc_section->GetObjectFile()); - if (m_symtab_up == nullptr) - m_symtab_up = - std::make_unique<Symtab>(reloc_section->GetObjectFile()); - - ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header, - reloc_id); + ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header, + reloc_id); + } } }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits