mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Teach identify_file_magic to identify PDB files.
llvm-svn: 326924
This commit is contained in:
parent
c1b5ea314a
commit
209938dde3
@ -45,7 +45,8 @@ struct file_magic {
|
||||
coff_import_library, ///< COFF import library
|
||||
pecoff_executable, ///< PECOFF executable file
|
||||
windows_resource, ///< Windows compiled resource file (.res)
|
||||
wasm_object ///< WebAssembly Object file
|
||||
wasm_object, ///< WebAssembly Object file
|
||||
pdb, ///< Windows PDB debug info file
|
||||
};
|
||||
|
||||
bool is_object() const { return V != unknown; }
|
||||
|
@ -181,7 +181,7 @@ file_magic llvm::identify_magic(StringRef Magic) {
|
||||
return file_magic::coff_object;
|
||||
break;
|
||||
|
||||
case 'M': // Possible MS-DOS stub on Windows PE file
|
||||
case 'M': // Possible MS-DOS stub on Windows PE file or MSF/PDB file.
|
||||
if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) {
|
||||
uint32_t off = read32le(Magic.data() + 0x3c);
|
||||
// PE/COFF file, either EXE or DLL.
|
||||
@ -189,6 +189,8 @@ file_magic llvm::identify_magic(StringRef Magic) {
|
||||
StringRef(COFF::PEMagic, sizeof(COFF::PEMagic))))
|
||||
return file_magic::pecoff_executable;
|
||||
}
|
||||
if (Magic.startswith("Microsoft C/C++ MSF 7.00\r\n"))
|
||||
return file_magic::pdb;
|
||||
break;
|
||||
|
||||
case 0x64: // x86-64 or ARM64 Windows.
|
||||
|
@ -81,6 +81,8 @@ const char windows_resource[] =
|
||||
const char macho_dynamically_linked_shared_lib_stub[] =
|
||||
"\xfe\xed\xfa\xce........\x00\x00\x00\x09............";
|
||||
const char ms_dos_stub_broken[] = "\x4d\x5a\x20\x20";
|
||||
const char pdb[] = "Microsoft C/C++ MSF 7.00\r\n\x1a"
|
||||
"DS\x00\x00\x00";
|
||||
|
||||
TEST_F(MagicTest, Magic) {
|
||||
struct type {
|
||||
@ -110,6 +112,7 @@ TEST_F(MagicTest, Magic) {
|
||||
DEFINE(macho_dsym_companion),
|
||||
DEFINE(macho_kext_bundle),
|
||||
DEFINE(windows_resource),
|
||||
DEFINE(pdb),
|
||||
{"ms_dos_stub_broken", ms_dos_stub_broken, sizeof(ms_dos_stub_broken),
|
||||
file_magic::unknown},
|
||||
#undef DEFINE
|
||||
|
Loading…
x
Reference in New Issue
Block a user