Skip to content

Commit bfc3db3

Browse files
committed
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.
1 parent e44c318 commit bfc3db3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/patchelf.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,12 @@ template<ElfFileParams>
557557
Elf_Shdr & ElfFile<ElfFileParamNames>::findSection(const SectionName & sectionName)
558558
{
559559
Elf_Shdr * shdr = findSection2(sectionName);
560-
if (!shdr)
561-
error("cannot find section '" + sectionName + "'");
560+
if (!shdr) {
561+
std::string extraMsg = "";
562+
if (sectionName == ".interp" || sectionName == ".dynamic" || sectionName == ".dynstr")
563+
extraMsg = ". The input file is most likely statically linked";
564+
error("cannot find section '" + sectionName + "'" + extraMsg);
565+
}
562566
return *shdr;
563567
}
564568

0 commit comments

Comments
 (0)