diff --git a/lib/checks/dependenciescheck.cpp b/lib/checks/dependenciescheck.cpp --- a/lib/checks/dependenciescheck.cpp +++ b/lib/checks/dependenciescheck.cpp @@ -47,6 +47,9 @@ for (int i = 0; i < fileSet->size(); ++i) { if (i != fileToCheck && fileToCheck >= 0) continue; + const auto *dynamicSection = fileSet->file(i)->dynamicSection(); + if (!dynamicSection) + continue; foreach (const auto &needed, fileSet->file(i)->dynamicSection()->neededLibraries()) { const auto depIdx = fileIndex.value(needed); const auto depFile = fileSet->file(depIdx); diff --git a/lib/elf/elffile.cpp b/lib/elf/elffile.cpp --- a/lib/elf/elffile.cpp +++ b/lib/elf/elffile.cpp @@ -206,13 +206,15 @@ m_sectionHeaders.push_back(shdr); } - // pass 2: create sections + // pass 2: create sections, if any // make sure the string table section needed for section names is created first - parseSection(m_header->stringTableSectionHeader()); - for (int i = 0; i < m_header->sectionHeaderCount(); ++i) { - if (i == m_header->stringTableSectionHeader()) - continue; - parseSection(i); + if (m_header->sectionHeaderCount() > 0) { + parseSection(m_header->stringTableSectionHeader()); + for (int i = 0; i < m_header->sectionHeaderCount(); ++i) { + if (i == m_header->stringTableSectionHeader()) + continue; + parseSection(i); + } } // pass 3: set section links