[Lldb-commits] [lldb] r214188 - When constructing an ArchSpec from a MachO cpu type and subtype, don't set the OS for x86_64 and x86 in case the binary ends up being for macosx or ios.

Greg Clayton gclayton at apple.com
Tue Jul 29 11:04:57 PDT 2014


Author: gclayton
Date: Tue Jul 29 13:04:57 2014
New Revision: 214188

URL: http://llvm.org/viewvc/llvm-project?rev=214188&view=rev
Log:
When constructing an ArchSpec from a MachO cpu type and subtype, don't set the OS for x86_64 and x86 in case the binary ends up being for macosx or ios.

<rdar://problem/17819272> 

Modified:
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=214188&r1=214187&r2=214188&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Tue Jul 29 13:04:57 2014
@@ -752,6 +752,15 @@ ArchSpec::SetArchitecture (ArchitectureT
                             
                         case llvm::Triple::x86:
                         case llvm::Triple::x86_64:
+                            // Don't set the OS for x86_64 or for x86 as we want to leave it as an "unspecified unknown"
+                            // which means if we ask for the OS from the llvm::Triple we get back llvm::Triple::UnknownOS, but
+                            // if we ask for the string value for the OS it will come back empty (unspecified).
+                            // We do this because we now have iOS and MacOSX as the OS values for x86 and x86_64 for
+                            // normal desktop and simulator binaries. And if we compare a "x86_64-apple-ios" to a "x86_64-apple-"
+                            // triple, it will say it is compatible (because the OS is unspecified in the second one and will match
+                            // anything in the first
+                            break;
+
                         default:
                             m_triple.setOS (llvm::Triple::MacOSX);
                             break;

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=214188&r1=214187&r2=214188&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Jul 29 13:04:57 2014
@@ -4365,10 +4365,14 @@ ObjectFileMachO::GetArchitecture (const
                 offset = cmd_offset + load_cmd.cmdsize;
             }
             
+            // Only set the OS to iOS for ARM, we don't want to set it for x86 and x86_64.
+            // We do this because we now have MacOSX or iOS as the OS value for x86 and
+            // x86_64 for normal desktop (MacOSX) and simulator (iOS) binaries. And if
+            // we compare a "x86_64-apple-ios" to a "x86_64-apple-" triple, it will say
+            // it is compatible (because the OS is unspecified in the second one and will
+            // match anything in the first
             if (header.cputype == CPU_TYPE_ARM || header.cputype == CPU_TYPE_ARM64)
                 triple.setOS (llvm::Triple::IOS);
-            else
-                triple.setOS (llvm::Triple::MacOSX);
         }
     }
     return arch.IsValid();





More information about the lldb-commits mailing list