| |
|
| static Cell groups[32] = { |
static Cell groups[32] = { |
| 0, |
0, |
| |
#undef GROUP |
| #define GROUP(x, n) DOESJUMP+1+n, |
#define GROUP(x, n) DOESJUMP+1+n, |
| #include "prim_grp.i" |
#include "prim_grp.i" |
| |
#undef GROUP |
| #define GROUP(x, n) |
#define GROUP(x, n) |
| }; |
}; |
| |
|
| void relocate(Cell *image, const char *bitstring, |
void relocate(Cell *image, const char *bitstring, |
| int size, int base, Label symbols[]) |
int size, Cell base, Label symbols[]) |
| { |
{ |
| int i=0, j, k, steps=(size/sizeof(Cell))/RELINFOBITS; |
int i=0, j, k, steps=(size/sizeof(Cell))/RELINFOBITS; |
| Cell token; |
Cell token; |
| PrimInfo *priminfos; |
PrimInfo *priminfos; |
| PrimInfo **decomp_prims; |
PrimInfo **decomp_prims; |
| |
|
| int compare_priminfo_length(PrimInfo **a, PrimInfo **b) |
int compare_priminfo_length(const void *_a, const void *_b) |
| { |
{ |
| |
PrimInfo **a = (PrimInfo **)_a; |
| |
PrimInfo **b = (PrimInfo **)_b; |
| Cell diff = (*a)->length - (*b)->length; |
Cell diff = (*a)->length - (*b)->length; |
| if (diff) |
if (diff) |
| return diff; |
return diff; |
| void check_prims(Label symbols1[]) |
void check_prims(Label symbols1[]) |
| { |
{ |
| int i; |
int i; |
| |
#ifndef NO_DYNAMIC |
| Label *symbols2, *symbols3, *ends1; |
Label *symbols2, *symbols3, *ends1; |
| static char superend[]={ |
static char superend[]={ |
| #include "prim_superend.i" |
#include "prim_superend.i" |
| }; |
}; |
| |
#endif |
| |
|
| if (debug) |
if (debug) |
| #ifdef __VERSION__ |
#ifdef __VERSION__ |
| #endif /* !defined(NO_DYNAMIC) */ |
#endif /* !defined(NO_DYNAMIC) */ |
| } |
} |
| |
|
| Label decompile_code(Label code) |
Label decompile_code(Label _code) |
| { |
{ |
| #ifdef NO_DYNAMIC |
#ifdef NO_DYNAMIC |
| return code; |
return _code; |
| #else /* !defined(NO_DYNAMIC) */ |
#else /* !defined(NO_DYNAMIC) */ |
| Cell i; |
Cell i; |
| struct code_block_list *p; |
struct code_block_list *p; |
| |
Address code=_code; |
| |
|
| /* first, check if we are in code at all */ |
/* first, check if we are in code at all */ |
| for (p = code_block_list;; p = p->next) { |
for (p = code_block_list;; p = p->next) { |
| *start=(Cell)prim; |
*start=(Cell)prim; |
| return; |
return; |
| } else { |
} else { |
| *start = prim-((Label)xts)+((Label)vm_prims); |
*start = (Cell)(prim-((Label)xts)+((Label)vm_prims)); |
| return; |
return; |
| } |
} |
| #elif defined(NO_IP) |
#elif defined(NO_IP) |
| alloc_stacks((ImageHeader *)imp); |
alloc_stacks((ImageHeader *)imp); |
| if (clear_dictionary) |
if (clear_dictionary) |
| memset(imp+header.image_size, 0, dictsize-header.image_size); |
memset(imp+header.image_size, 0, dictsize-header.image_size); |
| if(header.base==0 || header.base == 0x100) { |
if(header.base==0 || header.base == (Address)0x100) { |
| Cell reloc_size=((header.image_size-1)/sizeof(Cell))/8+1; |
Cell reloc_size=((header.image_size-1)/sizeof(Cell))/8+1; |
| char reloc_bits[reloc_size]; |
char reloc_bits[reloc_size]; |
| fseek(imagefile, preamblesize+header.image_size, SEEK_SET); |
fseek(imagefile, preamblesize+header.image_size, SEEK_SET); |
| fread(reloc_bits, 1, reloc_size, imagefile); |
fread(reloc_bits, 1, reloc_size, imagefile); |
| relocate((Cell *)imp, reloc_bits, header.image_size, header.base, vm_prims); |
relocate((Cell *)imp, reloc_bits, header.image_size, (Cell)header.base, vm_prims); |
| #if 0 |
#if 0 |
| { /* let's see what the relocator did */ |
{ /* let's see what the relocator did */ |
| FILE *snapshot=fopen("snapshot.fi","wb"); |
FILE *snapshot=fopen("snapshot.fi","wb"); |