File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -394,10 +394,13 @@ ElfFile<ElfFileParamNames>::ElfFile(FileContents fileContents)
394
394
error (" wrong ELF type" );
395
395
396
396
if ((size_t ) (rdi (hdr->e_phoff ) + rdi (hdr->e_phnum ) * rdi (hdr->e_phentsize )) > fileContents->size ())
397
- error (" missing program headers" );
397
+ error (" program header table out of bounds" );
398
+
399
+ if (rdi (hdr->e_shnum ) == 0 )
400
+ error (" no section headers. The input file is probably a statically linked, self-decompressing binary" );
398
401
399
402
if ((size_t ) (rdi (hdr->e_shoff ) + rdi (hdr->e_shnum ) * rdi (hdr->e_shentsize )) > fileContents->size ())
400
- error (" missing section headers " );
403
+ error (" section header table out of bounds " );
401
404
402
405
if (rdi (hdr->e_phentsize ) != sizeof (Elf_Phdr))
403
406
error (" program headers have wrong size" );
@@ -559,8 +562,12 @@ template<ElfFileParams>
559
562
Elf_Shdr & ElfFile<ElfFileParamNames>::findSection(const SectionName & sectionName)
560
563
{
561
564
Elf_Shdr * shdr = findSection2 (sectionName);
562
- if (!shdr)
563
- error (" cannot find section '" + sectionName + " '" );
565
+ if (!shdr) {
566
+ std::string extraMsg = " " ;
567
+ if (sectionName == " .interp" || sectionName == " .dynamic" || sectionName == " .dynstr" )
568
+ extraMsg = " . The input file is most likely statically linked" ;
569
+ error (" cannot find section '" + sectionName + " '" + extraMsg);
570
+ }
564
571
return *shdr;
565
572
}
566
573
You can’t perform that action at this time.
0 commit comments