aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-11-09 20:21:25 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-11-09 20:21:25 +0000
commit31391b6792e6c129b7dcb3ce290a21890699287e (patch)
tree290a12bd4d1d720233c565cb1cfc9f5084fc8598
parentb5810282eedb7ca8896f1159c714eec217490372 (diff)
downloadexternal_llvm-31391b6792e6c129b7dcb3ce290a21890699287e.zip
external_llvm-31391b6792e6c129b7dcb3ce290a21890699287e.tar.gz
external_llvm-31391b6792e6c129b7dcb3ce290a21890699287e.tar.bz2
Make sure llee can deal with compressed bytecode too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17652 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/llee/ExecveHandler.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/llee/ExecveHandler.c b/tools/llee/ExecveHandler.c
index 89d1536..c15c146 100644
--- a/tools/llee/ExecveHandler.c
+++ b/tools/llee/ExecveHandler.c
@@ -21,10 +21,11 @@
#include <string.h>
/*
- * This is the expected header for all valid LLVM bytecode files.
- * The first four characters must be exactly this.
+ * These are the expected headers for all valid LLVM bytecode files.
+ * The first four characters must be one of these.
*/
-static const char llvmHeader[] = "llvm";
+static const char llvmHeaderUncompressed[] = "llvm";
+static const char llvmHeaderCompressed[] = "llvc";
/*
* This replacement execve() function first checks the file to be executed
@@ -34,7 +35,7 @@ static const char llvmHeader[] = "llvm";
int execve(const char *filename, char *const argv[], char *const envp[])
{
/* Open the file, test to see if first four characters are "llvm" */
- size_t headerSize = strlen(llvmHeader);
+ size_t headerSize = strlen(llvmHeaderCompressed);
char header[headerSize];
char* realFilename = 0;
/*
@@ -57,7 +58,8 @@ int execve(const char *filename, char *const argv[], char *const envp[])
ssize_t bytesRead = read(file, header, headerSize);
close(file);
if (bytesRead != (ssize_t)headerSize) return EIO;
- if (!memcmp(llvmHeader, header, headerSize)) {
+ if (!memcmp(llvmHeaderCompressed, header, headerSize) ||
+ !memcmp(llvmHeaderUncompressed, header, headerSize)) {
/*
* This is a bytecode file, so execute the JIT with the program and
* parameters.