diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index b599c9c8868..0bd48490bb5 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -103,8 +103,16 @@ Path::isArchive() const { bool Path::isDynamicLibrary() const { - if (canRead()) - return hasMagicNumber("\177ELF"); + if (canRead()) { + std::string Magic; + if (getMagicNumber(Magic, 64)) + switch (IdentifyFileType(Magic.c_str(), Magic.length())) { + default: return false; + case ELF_FileType: + case Mach_O_FileType: + case COFF_FileType: return true; + } + } return false; }