diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-11 18:18:02 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-11 18:18:02 +0000 |
commit | af2c42e3d2ee918c4195ce5f32e732c43d93cea8 (patch) | |
tree | e0d0667ce19197d895f30fa8c8aaf9a975688053 /lib | |
parent | 0262db3b55301c6d6b75a432273e6b12d9cbbba9 (diff) | |
download | external_llvm-af2c42e3d2ee918c4195ce5f32e732c43d93cea8.zip external_llvm-af2c42e3d2ee918c4195ce5f32e732c43d93cea8.tar.gz external_llvm-af2c42e3d2ee918c4195ce5f32e732c43d93cea8.tar.bz2 |
Remove sys::identifyFileType.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183763 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/Path.cpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index bf1ae44..e53abe8 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -37,123 +37,6 @@ bool Path::operator<(const Path& that) const { return path < that.path; } -LLVMFileType -sys::identifyFileType(StringRef Magic) { - unsigned Length = Magic.size(); - assert(Length >= 4 && "Invalid magic number length"); - switch ((unsigned char)Magic[0]) { - case 0xDE: // 0x0B17C0DE = BC wraper - if (Magic[1] == (char)0xC0 && Magic[2] == (char)0x17 && - Magic[3] == (char)0x0B) - return Bitcode_FileType; - break; - case 'B': - if (Magic[1] == 'C' && Magic[2] == (char)0xC0 && Magic[3] == (char)0xDE) - return Bitcode_FileType; - break; - case '!': - if (Length >= 8) - if (memcmp(Magic.data(),"!<arch>\n",8) == 0) - return Archive_FileType; - break; - - case '\177': - if (Length >= 18 && Magic[1] == 'E' && Magic[2] == 'L' && - Magic[3] == 'F') { - bool Data2MSB = Magic[5] == 2; - unsigned high = Data2MSB ? 16 : 17; - unsigned low = Data2MSB ? 17 : 16; - if (Magic[high] == 0) - switch (Magic[low]) { - default: break; - case 1: return ELF_Relocatable_FileType; - case 2: return ELF_Executable_FileType; - case 3: return ELF_SharedObject_FileType; - case 4: return ELF_Core_FileType; - } - } - break; - - case 0xCA: - if (Magic[1] == char(0xFE) && Magic[2] == char(0xBA) && - Magic[3] == char(0xBE)) { - // This is complicated by an overlap with Java class files. - // See the Mach-O section in /usr/share/file/magic for details. - if (Length >= 8 && Magic[7] < 43) - // FIXME: Universal Binary of any type. - return Mach_O_DynamicallyLinkedSharedLib_FileType; - } - break; - - // The two magic numbers for mach-o are: - // 0xfeedface - 32-bit mach-o - // 0xfeedfacf - 64-bit mach-o - case 0xFE: - case 0xCE: - case 0xCF: { - uint16_t type = 0; - if (Magic[0] == char(0xFE) && Magic[1] == char(0xED) && - Magic[2] == char(0xFA) && - (Magic[3] == char(0xCE) || Magic[3] == char(0xCF))) { - /* Native endian */ - if (Length >= 16) type = Magic[14] << 8 | Magic[15]; - } else if ((Magic[0] == char(0xCE) || Magic[0] == char(0xCF)) && - Magic[1] == char(0xFA) && Magic[2] == char(0xED) && - Magic[3] == char(0xFE)) { - /* Reverse endian */ - if (Length >= 14) type = Magic[13] << 8 | Magic[12]; - } - switch (type) { - default: break; - case 1: return Mach_O_Object_FileType; - case 2: return Mach_O_Executable_FileType; - case 3: return Mach_O_FixedVirtualMemorySharedLib_FileType; - case 4: return Mach_O_Core_FileType; - case 5: return Mach_O_PreloadExecutable_FileType; - case 6: return Mach_O_DynamicallyLinkedSharedLib_FileType; - case 7: return Mach_O_DynamicLinker_FileType; - case 8: return Mach_O_Bundle_FileType; - case 9: return Mach_O_DynamicallyLinkedSharedLibStub_FileType; - case 10: return Mach_O_DSYMCompanion_FileType; - } - break; - } - case 0xF0: // PowerPC Windows - case 0x83: // Alpha 32-bit - case 0x84: // Alpha 64-bit - case 0x66: // MPS R4000 Windows - case 0x50: // mc68K - case 0x4c: // 80386 Windows - if (Magic[1] == 0x01) - return COFF_FileType; - - case 0x90: // PA-RISC Windows - case 0x68: // mc68K Windows - if (Magic[1] == 0x02) - return COFF_FileType; - break; - - case 0x4d: // Possible MS-DOS stub on Windows PE file - if (Magic[1] == 0x5a) { - uint32_t off = - *reinterpret_cast<const ulittle32_t *>(Magic.data() + 0x3c); - // PE/COFF file, either EXE or DLL. - if (off < Length && memcmp(Magic.data() + off, "PE\0\0",4) == 0) - return COFF_FileType; - } - break; - - case 0x64: // x86-64 Windows. - if (Magic[1] == char(0x86)) - return COFF_FileType; - break; - - default: - break; - } - return Unknown_FileType; -} - bool Path::isArchive() const { fs::file_magic type; |