Skip to content

Commit 4573354

Browse files
committed
guard against empty .interp and .dynamic
1 parent bcc4047 commit 4573354

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

view/elf/elfview.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,10 @@ bool ElfView::Init()
550550
break;
551551
}
552552

553-
if (!foundMatch)
553+
if (!foundMatch && i.memorySize)
554554
AddAutoSection(".dynamic", adjustedVirtualAddr, i.memorySize, ReadOnlyDataSectionSemantics, "DYNAMIC", i.align, entrySize);
555+
else if (!foundMatch)
556+
m_logger->LogWarn("Skipping zero-length .dynamic section at 0x%" PRIx64, adjustedVirtualAddr);
555557
}
556558
else if (i.type == ELF_PT_INTERP)
557559
{
@@ -572,8 +574,10 @@ bool ElfView::Init()
572574
break;
573575
}
574576

575-
if (!foundMatch)
577+
if (!foundMatch && i.memorySize)
576578
AddAutoSection(".interp", adjustedVirtualAddr, i.memorySize, ReadOnlyDataSectionSemantics, "PROGBITS", i.align);
579+
else if (!foundMatch)
580+
m_logger->LogWarn("Skipping zero-length .interp section at 0x%" PRIx64, adjustedVirtualAddr);
577581

578582
DefineDataVariable(adjustedVirtualAddr, Type::ArrayType(Type::IntegerType(1, true), i.fileSize));
579583
DefineAutoSymbol(new Symbol(DataSymbol, "__elf_interp", adjustedVirtualAddr, LocalBinding));

0 commit comments

Comments
 (0)