From 3062a1469da0569e714aa4634b29345f6d8c874c Mon Sep 17 00:00:00 2001 From: zhijian Date: Wed, 19 Jan 2022 12:18:45 -0500 Subject: [PATCH] [AIX] identify big archive magic as archive. Summary: identify big archive magic as archive. Reviewers: Hubert Tong Differential Revision: https://reviews.llvm.org/D117511 --- llvm/lib/BinaryFormat/Magic.cpp | 5 ++++- llvm/unittests/BinaryFormat/TestFileMagic.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp index 8c7f7b7..0c40bce 100644 --- a/llvm/lib/BinaryFormat/Magic.cpp +++ b/llvm/lib/BinaryFormat/Magic.cpp @@ -88,7 +88,10 @@ file_magic llvm::identify_magic(StringRef Magic) { 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 index 81c5f08..235e4bb 100644 --- a/llvm/unittests/BinaryFormat/TestFileMagic.cpp +++ b/llvm/unittests/BinaryFormat/TestFileMagic.cpp @@ -46,6 +46,7 @@ protected: }; 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 @@ TEST_F(MagicTest, Magic) { } 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), -- 2.7.4