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 @@ -88,7 +88,10 @@ if (startswith(Magic, "!\n") || startswith(Magic, "!\n")) return file_magic::archive; break; - + case '<': + if (startswith(Magic, "\n")) + return file_magic::archive; + break; case '\177': if (startswith(Magic, "\177ELF") && Magic.size() >= 18) { bool Data2MSB = Magic[5] == 2; 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 @@ -46,6 +46,7 @@ }; const char archive[] = "!\x0A"; +const char big_archive[] = "\x0A"; const char bitcode[] = "\xde\xc0\x17\x0b"; const char coff_object[] = "\x00\x00......"; const char coff_bigobj[] = @@ -96,6 +97,7 @@ } types[] = { #define DEFINE(magic) {#magic, magic, sizeof(magic), file_magic::magic} DEFINE(archive), + {"big_archive", big_archive, sizeof(big_archive), file_magic::archive}, DEFINE(bitcode), DEFINE(coff_object), {"coff_bigobj", coff_bigobj, sizeof(coff_bigobj),