Add support for 64-bit object files to Path.
authorEric Christopher <echristo@apple.com>
Fri, 22 Apr 2011 03:50:19 +0000 (03:50 +0000)
committerEric Christopher <echristo@apple.com>
Fri, 22 Apr 2011 03:50:19 +0000 (03:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129975 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Path.cpp

index cfe23d81c299556d5455fd4c7e34bcc7af7e6b6f..8fbaf2d42bf9f39c2c5994ff40f903e24cb0c78a 100644 (file)
@@ -92,15 +92,21 @@ sys::IdentifyFileType(const char *magic, unsigned length) {
       }
       break;
 
+      // The two magic numbers for mach-o are:
+      // 0xfeedface - 32-bit mach-o
+      // 0xfeedfacf - 64-bit mach-o
     case 0xFE:
-    case 0xCE: {
+    case 0xCE:
+    case 0xCF: {
       uint16_t type = 0;
       if (magic[0] == char(0xFE) && magic[1] == char(0xED) &&
-          magic[2] == char(0xFA) && magic[3] == char(0xCE)) {
+          magic[2] == char(0xFA) && 
+          (magic[3] == char(0xCE) || magic[3] == char(0xCF))) {
         /* Native endian */
         if (length >= 16) type = magic[14] << 8 | magic[15];
-      } else if (magic[0] == char(0xCE) && magic[1] == char(0xFA) &&
-                 magic[2] == char(0xED) && magic[3] == char(0xFE)) {
+      } else if ((magic[0] == char(0xCE) || magic[0] == char(0xCF)) &&
+                 magic[1] == char(0xFA) && magic[2] == char(0xED) &&
+                 magic[3] == char(0xFE)) {
         /* Reverse endian */
         if (length >= 14) type = magic[13] << 8 | magic[12];
       }