summaryrefslogtreecommitdiffstats
path: root/llvm/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
commitccd4d2c8e40bff7a25c3f231f85572a3dbd52baa (patch)
treeb906f1924cbe64f9507eaf180ed1ace29540c96e /llvm/lib/System/Path.cpp
parent5f6ee131b1fffb4de1626b29c76ce245b2f35f5d (diff)
downloadbcm5719-llvm-ccd4d2c8e40bff7a25c3f231f85572a3dbd52baa.tar.gz
bcm5719-llvm-ccd4d2c8e40bff7a25c3f231f85572a3dbd52baa.zip
Make isDynamicLibrary detect more than just an ELF file.
llvm-svn: 35874
Diffstat (limited to 'llvm/lib/System/Path.cpp')
-rw-r--r--llvm/lib/System/Path.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/System/Path.cpp b/llvm/lib/System/Path.cpp
index b599c9c8868..0bd48490bb5 100644
--- a/llvm/lib/System/Path.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud