llvm.org GIT mirror llvm / 330c819
Support: improve identify_magic to recognize COFF bigobj identify_magic recognized a COFF bigobj as an import library file. This patch fixes that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217627 91177308-0d34-0410-b5e6-96231b3b80d8 Rui Ueyama 5 years ago
2 changed file(s) with 12 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
900900 return file_magic::unknown;
901901 switch ((unsigned char)Magic[0]) {
902902 case 0x00: {
903 // COFF short import library file
903 // COFF bigobj or short import library file
904904 if (Magic[1] == (char)0x00 && Magic[2] == (char)0xff &&
905 Magic[3] == (char)0xff)
906 return file_magic::coff_import_library;
905 Magic[3] == (char)0xff) {
906 const char BigobjMagic[] =
907 "\xc7\xa1\xba\xd1\xee\xba\xa9\x4b\xaf\x20\xfa\xf6\x6a\xa4\xdc\xb8";
908 if (Magic.size() >= 28 &&
909 memcmp(Magic.data() + 12, BigobjMagic, sizeof(BigobjMagic)) == 0)
910 return file_magic::coff_object;
911 return file_magic::coff_import_library;
912 }
907913 // Windows resource file
908914 const char Expected[] = { 0, 0, 0, 0, '\x20', 0, 0, 0, '\xff' };
909915 if (Magic.size() >= sizeof(Expected) &&
482482 const char archive[] = "!\x0A";
483483 const char bitcode[] = "\xde\xc0\x17\x0b";
484484 const char coff_object[] = "\x00\x00......";
485 const char coff_bigobj[] = "\x00\x00\xff\xff........"
486 "\xc7\xa1\xba\xd1\xee\xba\xa9\x4b\xaf\x20\xfa\xf6\x6a\xa4\xdc\xb8";
485487 const char coff_import_library[] = "\x00\x00\xff\xff....";
486488 const char elf_relocatable[] = { 0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
487489 0, 0, 0, 0, 0, 0, 0, 0, 1 };
511513 DEFINE(archive),
512514 DEFINE(bitcode),
513515 DEFINE(coff_object),
516 { "coff_bigobj", coff_bigobj, sizeof(coff_bigobj), fs::file_magic::coff_object },
514517 DEFINE(coff_import_library),
515518 DEFINE(elf_relocatable),
516519 DEFINE(macho_universal_binary),