llvm.org GIT mirror llvm / df85654
Teach identify_file_magic to identify PDB files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326924 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
3 changed file(s) with 8 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
4444 coff_import_library, ///< COFF import library
4545 pecoff_executable, ///< PECOFF executable file
4646 windows_resource, ///< Windows compiled resource file (.res)
47 wasm_object ///< WebAssembly Object file
47 wasm_object, ///< WebAssembly Object file
48 pdb, ///< Windows PDB debug info file
4849 };
4950
5051 bool is_object() const { return V != unknown; }
180180 return file_magic::coff_object;
181181 break;
182182
183 case 'M': // Possible MS-DOS stub on Windows PE file
183 case 'M': // Possible MS-DOS stub on Windows PE file or MSF/PDB file.
184184 if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) {
185185 uint32_t off = read32le(Magic.data() + 0x3c);
186186 // PE/COFF file, either EXE or DLL.
188188 StringRef(COFF::PEMagic, sizeof(COFF::PEMagic))))
189189 return file_magic::pecoff_executable;
190190 }
191 if (Magic.startswith("Microsoft C/C++ MSF 7.00\r\n"))
192 return file_magic::pdb;
191193 break;
192194
193195 case 0x64: // x86-64 or ARM64 Windows.
8080 const char macho_dynamically_linked_shared_lib_stub[] =
8181 "\xfe\xed\xfa\xce........\x00\x00\x00\x09............";
8282 const char ms_dos_stub_broken[] = "\x4d\x5a\x20\x20";
83 const char pdb[] = "Microsoft C/C++ MSF 7.00\r\n\x1a"
84 "DS\x00\x00\x00";
8385
8486 TEST_F(MagicTest, Magic) {
8587 struct type {
109111 DEFINE(macho_dsym_companion),
110112 DEFINE(macho_kext_bundle),
111113 DEFINE(windows_resource),
114 DEFINE(pdb),
112115 {"ms_dos_stub_broken", ms_dos_stub_broken, sizeof(ms_dos_stub_broken),
113116 file_magic::unknown},
114117 #undef DEFINE