64 bit mach-o files have sections that only have 32 bit file offsets. If dsymutil tries to produce an invalid mach-o file, then error out with a good error string.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/tools/dsymutil/MachOUtils.cpp | ||
---|---|---|
325 | what does error() return? |
A little bike shedding about the error but otherwise this LGTM
llvm/tools/dsymutil/MachOUtils.cpp | ||
---|---|---|
325 |
llvm/tools/dsymutil/MachOUtils.cpp | ||
---|---|---|
325 | It prints the error and returns false. |
Yeah, the error reporting was doing this pattern everywhere else, and I didn't want to break the pattern, or switch all of dsymutil over the llvm::Error...
Remove old code that was incorrectly checking for a total 4GB byte size of the final produced file. This code didn't work as intended for universal mach-o files since it was ok for these files to be larger than 4GB, and it didn't work for skinny mach-o files since they can actually be larger than 4GB as long as no uint32_t file offset would exceed UINT32_MAX.
llvm/tools/dsymutil/dsymutil.cpp | ||
---|---|---|
732 | So instead of the check below we now want to check the fat binary. Something like this: uint64_t offset = 0; for(size_t i = 0; i < NeedsTempFiles.size() - 1; ++i) { ErrorOr<vfs::Status> stat = Options.LinkOpts.VFS->status(OutputLocationOrErr->DWARFFile); if(!stat) break; offset += stat->getSize(); if (offset > UINT32_MAX) WithColor::error() << "the fat binary has a slice with an offset exceeds 4GB and will produce an invalid mach-o file."; return EXIT_FAILURE; } |
Add size detection for universal files with a slice that starts beyond 4GB, and clean up the error message as requested.
Thanks Greg. LGTM with "Mach-O" everywhere for consistency.
llvm/tools/dsymutil/dsymutil.cpp | ||
---|---|---|
758 |
clang-format: please reformat the code