[llvm] 3062a14 - [AIX] identify big archive magic as archive.

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 19 09:19:10 PST 2022


Author: zhijian
Date: 2022-01-19T12:18:45-05:00
New Revision: 3062a1469da0569e714aa4634b29345f6d8c874c

URL: https://github.com/llvm/llvm-project/commit/3062a1469da0569e714aa4634b29345f6d8c874c
DIFF: https://github.com/llvm/llvm-project/commit/3062a1469da0569e714aa4634b29345f6d8c874c.diff

LOG: [AIX] identify big archive magic as archive.
Summary:

  identify big archive magic as archive.

Reviewers: Hubert Tong
Differential Revision: https://reviews.llvm.org/D117511

Added: 
    

Modified: 
    llvm/lib/BinaryFormat/Magic.cpp
    llvm/unittests/BinaryFormat/TestFileMagic.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp
index 8c7f7b7043a04..0c40bce22412d 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, "!<arch>\n") || startswith(Magic, "!<thin>\n"))
       return file_magic::archive;
     break;
-
+  case '<':
+    if (startswith(Magic, "<bigaf>\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 81c5f08cdafa2..235e4bb05f094 100644
--- a/llvm/unittests/BinaryFormat/TestFileMagic.cpp
+++ b/llvm/unittests/BinaryFormat/TestFileMagic.cpp
@@ -46,6 +46,7 @@ class MagicTest : public testing::Test {
 };
 
 const char archive[] = "!<arch>\x0A";
+const char big_archive[] = "<bigaf>\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),


        


More information about the llvm-commits mailing list