From: Misha Brukman Date: Mon, 24 Nov 2003 05:28:12 +0000 (+0000) Subject: Add ability to query if a file is a legitimate ELF shared object. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=17cca96735f3f7b4afeb44c67a0b191722ef6d20;p=oota-llvm.git 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 --- diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index cde288925be..02541d9e8af 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. ///