Skip to content

Commit cdac1d8

Browse files
committed
[MachO] Fatal error on invalid section index
When there are more than 255 sections, MachO object writer allows creation of object files which are potentially malformed. Currently, there is an assertion in object writer code that prevents it. But for distributions where assertions are turned on this still results in creation of malformed objects. Turning the assertion into an explicit fatal error.
1 parent c193eea commit cdac1d8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ void MachObjectWriter::computeSymbolTable(
646646
LocalSymbolData.push_back(MSD);
647647
} else {
648648
MSD.SectionIndex = SectionIndexMap.lookup(&Symbol.getSection());
649-
assert(MSD.SectionIndex && "Invalid section index!");
649+
if (!MSD.SectionIndex)
650+
report_fatal_error("Invalid section index!");
650651
LocalSymbolData.push_back(MSD);
651652
}
652653
}

0 commit comments

Comments
 (0)