aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-11-24 05:28:12 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-11-24 05:28:12 +0000
commit17cca96735f3f7b4afeb44c67a0b191722ef6d20 (patch)
tree7bb431098d071821e0d60918161e14fc6b54e7b6
parent3e4a271c891e98ace9f0833bf12fca75b03a2e8c (diff)
downloadexternal_llvm-17cca96735f3f7b4afeb44c67a0b191722ef6d20.zip
external_llvm-17cca96735f3f7b4afeb44c67a0b191722ef6d20.tar.gz
external_llvm-17cca96735f3f7b4afeb44c67a0b191722ef6d20.tar.bz2
Add ability to query if a file is a legitimate ELF shared object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10193 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/FileUtilities.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp
index cde2889..02541d9 100644
--- a/lib/Support/FileUtilities.cpp
+++ b/lib/Support/FileUtilities.cpp
@@ -52,6 +52,16 @@ bool IsBytecode(const std::string &FN) {
return CheckMagic (FN, "llvm");
}
+/// IsSharedObject - Returns trus IFF the file named FN appears to be a shared
+/// object with an ELF header. The file named FN must exist.
+///
+bool IsSharedObject(const std::string &FN) {
+ // Inspect the beginning of the file to see if it contains the LLVM
+ // bytecode format magic string.
+ static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' };
+ return CheckMagic(FN, elfMagic);
+}
+
/// FileOpenable - Returns true IFF Filename names an existing regular
/// file which we can successfully open.
///