[llvm] r217933 - Fix identify_magic() with mach-o stub dylibs.

Nick Kledzik kledzik at apple.com
Tue Sep 16 17:53:44 PDT 2014


Author: kledzik
Date: Tue Sep 16 19:53:44 2014
New Revision: 217933

URL: http://llvm.org/viewvc/llvm-project?rev=217933&view=rev
Log:
Fix identify_magic() with mach-o stub dylibs.

The wrong value was returned and the unittest did not cover the stub dylib case.



Modified:
    llvm/trunk/lib/Support/Path.cpp
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=217933&r1=217932&r2=217933&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Tue Sep 16 19:53:44 2014
@@ -999,7 +999,7 @@ file_magic identify_magic(StringRef Magi
         case 6: return file_magic::macho_dynamically_linked_shared_lib;
         case 7: return file_magic::macho_dynamic_linker;
         case 8: return file_magic::macho_bundle;
-        case 9: return file_magic::macho_dynamic_linker;
+        case 9: return file_magic::macho_dynamically_linked_shared_lib_stub;
         case 10: return file_magic::macho_dsym_companion;
       }
       break;

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=217933&r1=217932&r2=217933&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Tue Sep 16 19:53:44 2014
@@ -501,6 +501,8 @@ const char macho_dynamic_linker[] = "\xf
 const char macho_bundle[] = "\xfe\xed\xfa\xce..........\x00\x08";
 const char macho_dsym_companion[] = "\xfe\xed\xfa\xce..........\x00\x0a";
 const char windows_resource[] = "\x00\x00\x00\x00\x020\x00\x00\x00\xff";
+const char macho_dynamically_linked_shared_lib_stub[] =
+    "\xfe\xed\xfa\xce..........\x00\x09";
 
 TEST_F(FileSystemTest, Magic) {
   struct type {
@@ -526,6 +528,7 @@ TEST_F(FileSystemTest, Magic) {
     DEFINE(macho_dynamically_linked_shared_lib),
     DEFINE(macho_dynamic_linker),
     DEFINE(macho_bundle),
+    DEFINE(macho_dynamically_linked_shared_lib_stub),
     DEFINE(macho_dsym_companion),
     DEFINE(windows_resource)
 #undef DEFINE





More information about the llvm-commits mailing list