Skip to content

Commit 534ac82

Browse files
authored
Merge pull request #6426 from apple/🍒/fantasia/244a6acff0b8c3bac93949e262166b5f1fe12b1f
[dsymutil] Fix offset calculation for universal binaries
2 parents 6b16dea + 608316d commit 534ac82

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/tools/dsymutil/dsymutil.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "llvm/Support/CrashRecoveryContext.h"
3737
#include "llvm/Support/FileCollector.h"
3838
#include "llvm/Support/FileSystem.h"
39+
#include "llvm/Support/FormatVariadic.h"
3940
#include "llvm/Support/InitLLVM.h"
4041
#include "llvm/Support/Path.h"
4142
#include "llvm/Support/TargetSelect.h"
@@ -796,12 +797,14 @@ int dsymutil_main(int argc, char **argv) {
796797
ErrorOr<vfs::Status> stat = Options.LinkOpts.VFS->status(File.path());
797798
if (!stat)
798799
break;
799-
FileOffset += stat->getSize();
800800
if (FileOffset > UINT32_MAX) {
801-
WithColor::error() << "the universal binary has a slice with an "
802-
"offset exceeds 4GB and will produce an invalid Mach-O file.";
801+
WithColor::error() << formatv(
802+
"the universal binary has a slice with a starting offset ({0:x}) "
803+
"that exceeds 4GB and will produce an invalid Mach-O file.",
804+
FileOffset);
803805
return EXIT_FAILURE;
804806
}
807+
FileOffset += stat->getSize();
805808
}
806809
if (!MachOUtils::generateUniversalBinary(TempFiles,
807810
OutputLocationOrErr->DWARFFile,

0 commit comments

Comments
 (0)