[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp

Misha Brukman brukman at cs.uiuc.edu
Sun Nov 23 23:29:01 PST 2003


Changes in directory llvm/lib/Support:

FileUtilities.cpp updated: 1.11 -> 1.12

---
Log message:

Add ability to query if a file is a legitimate ELF shared object.


---
Diffs of the changes:  (+10 -0)

Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.11 llvm/lib/Support/FileUtilities.cpp:1.12
--- llvm/lib/Support/FileUtilities.cpp:1.11	Tue Nov 11 16:41:33 2003
+++ llvm/lib/Support/FileUtilities.cpp	Sun Nov 23 23:28:12 2003
@@ -52,6 +52,16 @@
   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.
 ///





More information about the llvm-commits mailing list