From a7ad4b3f3b841a95510ddaab2ee4e998d9ed0a2a Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 25 Feb 2015 22:59:20 +0000 Subject: [PATCH] Object: Handle Mach-O kext bundle files This particular subtype of Mach-O was missing. Add it. llvm-svn: 230567 --- llvm/include/llvm/Support/FileSystem.h | 1 + llvm/lib/Object/Binary.cpp | 1 + llvm/lib/Object/ObjectFile.cpp | 1 + llvm/lib/Object/SymbolicFile.cpp | 1 + llvm/lib/Support/Path.cpp | 1 + llvm/unittests/Support/Path.cpp | 2 ++ 6 files changed, 7 insertions(+) diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h index 8c02908b639b..b3b44c46653b 100644 --- a/llvm/include/llvm/Support/FileSystem.h +++ b/llvm/include/llvm/Support/FileSystem.h @@ -241,6 +241,7 @@ struct file_magic { macho_bundle, ///< Mach-O Bundle file macho_dynamically_linked_shared_lib_stub, ///< Mach-O Shared lib stub macho_dsym_companion, ///< Mach-O dSYM companion file + macho_kext_bundle, ///< Mach-O kext bundle file macho_universal_binary, ///< Mach-O universal binary coff_object, ///< COFF object file coff_import_library, ///< COFF import library diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp index c56eeb1ea8b8..a2b167a665c5 100644 --- a/llvm/lib/Object/Binary.cpp +++ b/llvm/lib/Object/Binary.cpp @@ -58,6 +58,7 @@ ErrorOr> object::createBinary(MemoryBufferRef Buffer, case sys::fs::file_magic::macho_bundle: case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub: case sys::fs::file_magic::macho_dsym_companion: + case sys::fs::file_magic::macho_kext_bundle: case sys::fs::file_magic::coff_object: case sys::fs::file_magic::coff_import_library: case sys::fs::file_magic::pecoff_executable: diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp index fd7827142532..01b76543fa2e 100644 --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -76,6 +76,7 @@ ObjectFile::createObjectFile(MemoryBufferRef Object, sys::fs::file_magic Type) { case sys::fs::file_magic::macho_bundle: case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub: case sys::fs::file_magic::macho_dsym_companion: + case sys::fs::file_magic::macho_kext_bundle: return createMachOObjectFile(Object); case sys::fs::file_magic::coff_object: case sys::fs::file_magic::coff_import_library: diff --git a/llvm/lib/Object/SymbolicFile.cpp b/llvm/lib/Object/SymbolicFile.cpp index de98a1228cd4..854e68e40f4d 100644 --- a/llvm/lib/Object/SymbolicFile.cpp +++ b/llvm/lib/Object/SymbolicFile.cpp @@ -53,6 +53,7 @@ ErrorOr> SymbolicFile::createSymbolicFile( case sys::fs::file_magic::macho_bundle: case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub: case sys::fs::file_magic::macho_dsym_companion: + case sys::fs::file_magic::macho_kext_bundle: case sys::fs::file_magic::coff_import_library: case sys::fs::file_magic::pecoff_executable: return ObjectFile::createObjectFile(Object, Type); diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index abec7b9dd221..a11bb7feea03 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1012,6 +1012,7 @@ file_magic identify_magic(StringRef Magic) { case 8: return file_magic::macho_bundle; case 9: return file_magic::macho_dynamically_linked_shared_lib_stub; case 10: return file_magic::macho_dsym_companion; + case 11: return file_magic::macho_kext_bundle; } break; } diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 0d661c8ae6c0..00af989f4857 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -557,6 +557,7 @@ const char macho_dynamically_linked_shared_lib[] = const char macho_dynamic_linker[] = "\xfe\xed\xfa\xce..........\x00\x07"; const char macho_bundle[] = "\xfe\xed\xfa\xce..........\x00\x08"; const char macho_dsym_companion[] = "\xfe\xed\xfa\xce..........\x00\x0a"; +const char macho_kext_bundle[] = "\xfe\xed\xfa\xce..........\x00\x0b"; 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"; @@ -587,6 +588,7 @@ TEST_F(FileSystemTest, Magic) { DEFINE(macho_bundle), DEFINE(macho_dynamically_linked_shared_lib_stub), DEFINE(macho_dsym_companion), + DEFINE(macho_kext_bundle), DEFINE(windows_resource) #undef DEFINE };