Improve error message when run on statically linked binaries

If .dynamic, .dynstr or .interp sections aren't found, give an extra hint
to the user that the input file is statically linked.
This commit is contained in:
Tuomas Tynkkynen
2017-04-19 17:14:19 +03:00
parent e44c318b37
commit bfc3db32d2

View File

@@ -557,8 +557,12 @@ template<ElfFileParams>
Elf_Shdr & ElfFile<ElfFileParamNames>::findSection(const SectionName & sectionName) Elf_Shdr & ElfFile<ElfFileParamNames>::findSection(const SectionName & sectionName)
{ {
Elf_Shdr * shdr = findSection2(sectionName); Elf_Shdr * shdr = findSection2(sectionName);
if (!shdr) if (!shdr) {
error("cannot find section '" + sectionName + "'"); std::string extraMsg = "";
if (sectionName == ".interp" || sectionName == ".dynamic" || sectionName == ".dynstr")
extraMsg = ". The input file is most likely statically linked";
error("cannot find section '" + sectionName + "'" + extraMsg);
}
return *shdr; return *shdr;
} }