Skip to content

Commit 1ec03f3

Browse files
committed
[dsymutil] Emit an error when the Mach-O exceeds the 4GB limit.
The Mach-O object file format is limited to 4GB because its used of 32-bit offsets in the header. It is possible for dsymutil to (silently) emit an invalid binary. Instead of having consumers deal with this, emit an error instead.
1 parent 7bf7b80 commit 1ec03f3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

llvm/tools/dsymutil/dsymutil.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,19 @@ int main(int argc, char **argv) {
689689
Options.LinkOpts, SDKPath))
690690
return EXIT_FAILURE;
691691
}
692+
693+
// The Mach-O object file format is limited to 4GB. Make sure that we print
694+
// an error when we emit an invalid Mach-O companion file. Leave the
695+
// invalid object file around on disk for inspection.
696+
ErrorOr<vfs::Status> stat =
697+
Options.LinkOpts.VFS->status(OutputLocationOrErr->DWARFFile);
698+
if (stat) {
699+
if (stat->getSize() > std::numeric_limits<uint32_t>::max()) {
700+
WithColor::error() << "the linked debug info exceeds the 4GB Mach-O "
701+
"object file format.";
702+
return EXIT_FAILURE;
703+
}
704+
}
692705
}
693706

694707
return EXIT_SUCCESS;

0 commit comments

Comments
 (0)