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_PreloadExectuable_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;
if (magic[1] == 0x02)
return COFF_FileType;
break;
+ case 0x64: // x86-64 Windows.
+ if (magic[1] == char(0x86))
+ return COFF_FileType;
+ break;
default:
break;
return false;
}
+bool
+Path::isObjectFile() const {
+ std::string Magic;
+ if (getMagicNumber(Magic, 64))
+ if (IdentifyFileType(Magic.c_str(),
+ static_cast<unsigned>(Magic.length()))
+ != Unknown_FileType) {
+ // Everything in LLVMFileType is currently an object file.
+ return true;
+ }
+
+ return false;
+}
+
Path
Path::FindLibrary(std::string& name) {
std::vector<sys::Path> LibPaths;
}
StringRef Path::GetDLLSuffix() {
- return LTDL_SHLIB_EXT;
+ return &(LTDL_SHLIB_EXT[1]);
+}
+
+bool
+Path::appendSuffix(StringRef suffix) {
+ if (!suffix.empty()) {
+ std::string save(path);
+ path.append(".");
+ path.append(suffix);
+ if (!isValid()) {
+ path = save;
+ return false;
+ }
+ }
+
+ return true;
}
bool