[PATCH] D121396: Fix dsymutil to handle universal files that exceed 4GB.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 11:13:00 PST 2022


clayborg created this revision.
clayborg added reviewers: JDevlieghere, aprantl, aadsm, wallace, yinghuitan.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This fixes a bug where if a unviversal mach-o file exceeded 4GB, dsymutil would return an error even if each slice was under 4GB in size, but the total universal file size exceeded 4GB.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121396

Files:
  llvm/tools/dsymutil/dsymutil.cpp


Index: llvm/tools/dsymutil/dsymutil.cpp
===================================================================
--- llvm/tools/dsymutil/dsymutil.cpp
+++ llvm/tools/dsymutil/dsymutil.cpp
@@ -734,18 +734,22 @@
                                                OutputLocationOrErr->DWARFFile,
                                                Options.LinkOpts, SDKPath))
         return EXIT_FAILURE;
-    }
-
-    // The Mach-O object file format is limited to 4GB. Make sure that we print
-    // an error when we emit an invalid Mach-O companion file. Leave the
-    // invalid object file around on disk for inspection.
-    ErrorOr<vfs::Status> stat =
-        Options.LinkOpts.VFS->status(OutputLocationOrErr->DWARFFile);
-    if (stat) {
-      if (stat->getSize() > std::numeric_limits<uint32_t>::max()) {
-        WithColor::error() << "the linked debug info exceeds the 4GB Mach-O "
-                              "object file format.";
-        return EXIT_FAILURE;
+    } else {
+      // Only check the size of a skinny mach-o file. If we use temp files then
+      // we have multiple architectures and the "lipo" command will fail to
+      // produce a valid universal file if any file is over 4GB in size.
+
+      // The Mach-O object file format is limited to 4GB. Make sure that we
+      // print an error when we emit an invalid Mach-O companion file. Leave the
+      // invalid object file around on disk for inspection.
+      ErrorOr<vfs::Status> stat =
+          Options.LinkOpts.VFS->status(OutputLocationOrErr->DWARFFile);
+      if (stat) {
+        if (stat->getSize() > std::numeric_limits<uint32_t>::max()) {
+          WithColor::error() << "the linked debug info exceeds the 4GB Mach-O "
+                                "object file format.";
+          return EXIT_FAILURE;
+        }
       }
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121396.414440.patch
Type: text/x-patch
Size: 1833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220310/af8329d2/attachment.bin>


More information about the llvm-commits mailing list