Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 290c772

Browse files
author
Nick Kledzik
committed
Fix identify_magic() with mach-o stub dylibs.
The wrong value was returned and the unittest did not cover the stub dylib case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217933 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 2b90611 commit 290c772

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/Support/Path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ file_magic identify_magic(StringRef Magic) {
999999
case 6: return file_magic::macho_dynamically_linked_shared_lib;
10001000
case 7: return file_magic::macho_dynamic_linker;
10011001
case 8: return file_magic::macho_bundle;
1002-
case 9: return file_magic::macho_dynamic_linker;
1002+
case 9: return file_magic::macho_dynamically_linked_shared_lib_stub;
10031003
case 10: return file_magic::macho_dsym_companion;
10041004
}
10051005
break;

unittests/Support/Path.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ const char macho_dynamic_linker[] = "\xfe\xed\xfa\xce..........\x00\x07";
501501
const char macho_bundle[] = "\xfe\xed\xfa\xce..........\x00\x08";
502502
const char macho_dsym_companion[] = "\xfe\xed\xfa\xce..........\x00\x0a";
503503
const char windows_resource[] = "\x00\x00\x00\x00\x020\x00\x00\x00\xff";
504+
const char macho_dynamically_linked_shared_lib_stub[] =
505+
"\xfe\xed\xfa\xce..........\x00\x09";
504506

505507
TEST_F(FileSystemTest, Magic) {
506508
struct type {
@@ -526,6 +528,7 @@ TEST_F(FileSystemTest, Magic) {
526528
DEFINE(macho_dynamically_linked_shared_lib),
527529
DEFINE(macho_dynamic_linker),
528530
DEFINE(macho_bundle),
531+
DEFINE(macho_dynamically_linked_shared_lib_stub),
529532
DEFINE(macho_dsym_companion),
530533
DEFINE(windows_resource)
531534
#undef DEFINE

0 commit comments

Comments
 (0)