summaryrefslogtreecommitdiff
path: root/lib/System/Path.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-11 00:49:39 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-11 00:49:39 +0000
commit410aa020a2c834a5029bb98ee44691c0ec6f2c53 (patch)
tree0fe242b36a09b097d2f5559e5542914a4dedf09c /lib/System/Path.cpp
parentc9f1b2d4c67b0e8337d694b362aa36c6db9a519c (diff)
downloadllvm-410aa020a2c834a5029bb98ee44691c0ec6f2c53.tar.gz
llvm-410aa020a2c834a5029bb98ee44691c0ec6f2c53.tar.bz2
llvm-410aa020a2c834a5029bb98ee44691c0ec6f2c53.tar.xz
Make isDynamicLibrary detect more than just an ELF file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Path.cpp')
-rw-r--r--lib/System/Path.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp
index b599c9c886..0bd48490bb 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;
}