diff --git a/llvm/include/llvm/BinaryFormat/Magic.h b/llvm/include/llvm/BinaryFormat/Magic.h --- a/llvm/include/llvm/BinaryFormat/Magic.h +++ b/llvm/include/llvm/BinaryFormat/Magic.h @@ -27,6 +27,7 @@ elf_executable, ///< ELF Executable image elf_shared_object, ///< ELF dynamically linked shared lib elf_core, ///< ELF core image + goff_object, ///< GOFF object file macho_object, ///< Mach-O Object file macho_executable, ///< Mach-O Executable macho_fixed_virtual_memory_shared_lib, ///< Mach-O Shared Lib, FVM diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp --- a/llvm/lib/BinaryFormat/Magic.cpp +++ b/llvm/lib/BinaryFormat/Magic.cpp @@ -71,6 +71,11 @@ return file_magic::xcoff_object_64; break; + case 0x03: + if (startswith(Magic, "\x03\xF0\x00")) + return file_magic::goff_object; + break; + case 0xDE: // 0x0B17C0DE = BC wraper if (startswith(Magic, "\xDE\xC0\x17\x0B")) return file_magic::bitcode; diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp --- a/llvm/lib/Object/Binary.cpp +++ b/llvm/lib/Object/Binary.cpp @@ -56,6 +56,7 @@ case file_magic::elf_executable: case file_magic::elf_shared_object: case file_magic::elf_core: + case file_magic::goff_object: case file_magic::macho_object: case file_magic::macho_executable: case file_magic::macho_fixed_virtual_memory_shared_lib: diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -145,6 +145,7 @@ case file_magic::windows_resource: case file_magic::pdb: case file_magic::minidump: + case file_magic::goff_object: return errorCodeToError(object_error::invalid_file_type); case file_magic::tapi_file: return errorCodeToError(object_error::invalid_file_type); diff --git a/llvm/lib/Object/SymbolicFile.cpp b/llvm/lib/Object/SymbolicFile.cpp --- a/llvm/lib/Object/SymbolicFile.cpp +++ b/llvm/lib/Object/SymbolicFile.cpp @@ -53,6 +53,7 @@ case file_magic::elf_executable: case file_magic::elf_shared_object: case file_magic::elf_core: + case file_magic::goff_object: case file_magic::macho_executable: case file_magic::macho_fixed_virtual_memory_shared_lib: case file_magic::macho_core: @@ -102,6 +103,7 @@ case file_magic::elf_executable: case file_magic::elf_shared_object: case file_magic::elf_core: + case file_magic::goff_object: case file_magic::macho_executable: case file_magic::macho_fixed_virtual_memory_shared_lib: case file_magic::macho_core: diff --git a/llvm/unittests/BinaryFormat/TestFileMagic.cpp b/llvm/unittests/BinaryFormat/TestFileMagic.cpp --- a/llvm/unittests/BinaryFormat/TestFileMagic.cpp +++ b/llvm/unittests/BinaryFormat/TestFileMagic.cpp @@ -54,6 +54,8 @@ const char coff_import_library[] = "\x00\x00\xff\xff...."; const char elf_relocatable[] = {0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; + +const char goff_object[] = "\x03\xF0\x00"; const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\x00"; const char macho_object[] = "\xfe\xed\xfa\xce........\x00\x00\x00\x01............"; @@ -100,6 +102,7 @@ file_magic::coff_object}, DEFINE(coff_import_library), DEFINE(elf_relocatable), + DEFINE(goff_object), DEFINE(macho_universal_binary), DEFINE(macho_object), DEFINE(macho_executable),