version 1.46, 2001/09/16 08:59:48
|
version 1.47, 2001/12/24 14:09:08
|
Line 144 void relocate(Cell *image, const char *b
|
Line 144 void relocate(Cell *image, const char *b
|
|
|
for (max_symbols=DOESJUMP+1; symbols[max_symbols]!=0; max_symbols++) |
for (max_symbols=DOESJUMP+1; symbols[max_symbols]!=0; max_symbols++) |
; |
; |
|
max_symbols--; |
size/=sizeof(Cell); |
size/=sizeof(Cell); |
|
|
for(k=0; k<=steps; k++) { |
for(k=0; k<=steps; k++) { |
Line 427 void print_sizes(Cell sizebyte)
|
Line 428 void print_sizes(Cell sizebyte)
|
1 << ((sizebyte >> 5) & 3)); |
1 << ((sizebyte >> 5) & 3)); |
} |
} |
|
|
|
typedef struct { |
|
Label start; |
|
Cell length; /* excluding the jump */ |
|
char super_end; /* true if primitive ends superinstruction, i.e., |
|
unconditional branch, execute, etc. */ |
|
} PrimInfo; |
|
|
|
PrimInfo *priminfos; |
|
|
|
void check_prims(Label symbols1[]) |
|
{ |
|
#ifndef DOUBLY_INDIRECT |
|
int i; |
|
Label *symbols2=engine2(0,0,0,0,0); |
|
|
|
for (i=DOESJUMP+1; symbols1[i+1]!=0; i++) |
|
; |
|
priminfos = calloc(i,sizeof(PrimInfo)); |
|
for (i=DOESJUMP+1; symbols1[i+1]!=0; i++) { |
|
int prim_len=symbols1[i+1]-symbols1[i]; |
|
PrimInfo *pi=&priminfos[i]; |
|
int j; |
|
for (j=prim_len-3; ; j--) { |
|
if (((*(Cell *)(symbols1[i]+j)) & 0xfff8ff) == 0xfc60ff) { |
|
/* jmp -4(reg), i.e., the NEXT jump */ |
|
prim_len = j; |
|
break; |
|
} |
|
if (j==0) { /* NEXT jump not found, e.g., execute */ |
|
pi->super_end = 1; |
|
break; |
|
} |
|
} |
|
/* fprintf(stderr,"checking primitive %d: memcmp(%p, %p, %d)\n", |
|
i, symbols1[i], symbols2[i], prim_len);*/ |
|
if (memcmp(symbols1[i],symbols2[i],prim_len)!=0) { |
|
if (debug) |
|
fprintf(stderr,"Primitive %d not relocatable: memcmp(%p, %p, %d)\n", |
|
i, symbols1[i], symbols2[i], prim_len); |
|
} else { |
|
pi->start = symbols1[i]; |
|
pi->length = prim_len; |
|
if (debug) |
|
fprintf(stderr,"Primitive %d relocatable: start %p, length %ld, super_end %d\n", |
|
i, pi->start, pi->length, pi->super_end); |
|
} |
|
} |
|
#endif |
|
} |
|
|
Address loader(FILE *imagefile, char* filename) |
Address loader(FILE *imagefile, char* filename) |
/* returns the address of the image proper (after the preamble) */ |
/* returns the address of the image proper (after the preamble) */ |
{ |
{ |
Line 456 Address loader(FILE *imagefile, char* fi
|
Line 507 Address loader(FILE *imagefile, char* fi
|
; |
; |
|
|
vm_prims = engine(0,0,0,0,0); |
vm_prims = engine(0,0,0,0,0); |
|
check_prims(vm_prims); |
#ifndef DOUBLY_INDIRECT |
#ifndef DOUBLY_INDIRECT |
check_sum = checksum(vm_prims); |
check_sum = checksum(vm_prims); |
#else /* defined(DOUBLY_INDIRECT) */ |
#else /* defined(DOUBLY_INDIRECT) */ |