mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
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
This commit is contained in:
@@ -21,10 +21,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the expected header for all valid LLVM bytecode files.
|
* These are the expected headers for all valid LLVM bytecode files.
|
||||||
* The first four characters must be exactly this.
|
* 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
|
* 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[])
|
int execve(const char *filename, char *const argv[], char *const envp[])
|
||||||
{
|
{
|
||||||
/* Open the file, test to see if first four characters are "llvm" */
|
/* 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 header[headerSize];
|
||||||
char* realFilename = 0;
|
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);
|
ssize_t bytesRead = read(file, header, headerSize);
|
||||||
close(file);
|
close(file);
|
||||||
if (bytesRead != (ssize_t)headerSize) return EIO;
|
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
|
* This is a bytecode file, so execute the JIT with the program and
|
||||||
* parameters.
|
* parameters.
|
||||||
|
Reference in New Issue
Block a user