|
|
@ -861,7 +861,9 @@ void vm_load_file(char *filename) |
|
|
|
char *ptr; |
|
|
|
char *ptr; |
|
|
|
|
|
|
|
|
|
|
|
fh = fopen(filename, "r"); |
|
|
|
fh = fopen(filename, "r"); |
|
|
|
assert(fh != NULL); |
|
|
|
if (fh == NULL) { |
|
|
|
|
|
|
|
err(1, "Failed to open '%s'", filename); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (ptr = vm_codearea; ptr < vm_codearea+vm_codesize; ptr++) { |
|
|
|
for (ptr = vm_codearea; ptr < vm_codearea+vm_codesize; ptr++) { |
|
|
|
int c; |
|
|
|
int c; |
|
|
@ -887,16 +889,19 @@ void vm_init_functions(void) |
|
|
|
struct hashentry *ptr; |
|
|
|
struct hashentry *ptr; |
|
|
|
|
|
|
|
|
|
|
|
/* First, let's check the magic */ |
|
|
|
/* First, let's check the magic */ |
|
|
|
assert(vm_codearea[0] == MAGIC1); |
|
|
|
if ((vm_codearea[0] != MAGIC1) || |
|
|
|
assert(vm_codearea[1] == MAGIC2); |
|
|
|
(vm_codearea[1] != MAGIC2)) |
|
|
|
assert(vm_codearea[2] == VERSION1); |
|
|
|
errx(1, "Bad magic - not a lightscript binary"); |
|
|
|
assert(vm_codearea[3] == VERSION2); |
|
|
|
if ((vm_codearea[2] != VERSION1) || |
|
|
|
|
|
|
|
(vm_codearea[3] != VERSION2)) |
|
|
|
assert(GETINT(vm_codearea, 8) == vm_abiversion1); |
|
|
|
errx(1, "Bad version - recompile"); |
|
|
|
assert(GETINT(vm_codearea, 12) == vm_abiversion2); |
|
|
|
|
|
|
|
assert(GETINT(vm_codearea, 16) == vm_abiversion3); |
|
|
|
if ((GETINT(vm_codearea, 8) != vm_abiversion1) || |
|
|
|
assert(GETINT(vm_codearea, 20) == vm_abiversion4); |
|
|
|
(GETINT(vm_codearea, 12) == vm_abiversion2) || |
|
|
|
assert(GETINT(vm_codearea, 24) == vm_abiversion5); |
|
|
|
(GETINT(vm_codearea, 16) == vm_abiversion3) || |
|
|
|
|
|
|
|
(GETINT(vm_codearea, 20) == vm_abiversion4) || |
|
|
|
|
|
|
|
(GETINT(vm_codearea, 24) == vm_abiversion5)) |
|
|
|
|
|
|
|
errx(1, "Incompatible ABI version - recompile"); |
|
|
|
|
|
|
|
|
|
|
|
/* Now, get the function table pointer */ |
|
|
|
/* Now, get the function table pointer */ |
|
|
|
t = GETINT(vm_codearea, 4); |
|
|
|
t = GETINT(vm_codearea, 4); |
|
|
|