Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/include/llvm/Object/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace object {
const char ArchiveMagic[] = "!<arch>\n";
const char ThinArchiveMagic[] = "!<thin>\n";
const char BigArchiveMagic[] = "<bigaf>\n";
const char ZOSArchiveMagic[] =
"\x5A\x4C\x81\x99\x83\x88\x6E\x15"; // "!<arch>\n" in EBCDIC

class Archive;

Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/BinaryFormat/Magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ file_magic llvm::identify_magic(StringRef Magic) {
if (startswith(Magic, "CPCH"))
return file_magic::clang_ast;
break;
case 0x5A:
if (startswith(Magic,
"\x5A\x4C\x81\x99\x83\x88\x6E\x15")) // "!<arch>\n" in EBCDIC
return file_magic::archive;
break;
case '!':
if (startswith(Magic, "!<arch>\n") || startswith(Magic, "!<thin>\n"))
return file_magic::archive;
Expand Down
2 changes: 2 additions & 0 deletions llvm/unittests/BinaryFormat/TestFileMagic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MagicTest : public testing::Test {

const char archive[] = "!<arch>\x0A";
const char big_archive[] = "<bigaf>\x0A";
const char zos_archive[] = "\x5A\x4C\x81\x99\x83\x88\x6E\x15";
const char bitcode[] = "\xde\xc0\x17\x0b";
const char coff_object[] = "\x00\x00......";
const char coff_bigobj[] =
Expand Down Expand Up @@ -100,6 +101,7 @@ TEST_F(MagicTest, Magic) {
#define DEFINE(magic) {#magic, magic, sizeof(magic), file_magic::magic}
DEFINE(archive),
{"big_archive", big_archive, sizeof(big_archive), file_magic::archive},
{"zos_archive", zos_archive, sizeof(zos_archive), file_magic::archive},
DEFINE(bitcode),
DEFINE(coff_object),
{"coff_bigobj", coff_bigobj, sizeof(coff_bigobj),
Expand Down