version 1.14, 1998/12/20 23:17:56
|
version 1.15, 1998/12/22 15:19:03
|
Line 78 static int debug=0;
|
Line 78 static int debug=0;
|
char *progname; |
char *progname; |
|
|
/* image file format: |
/* image file format: |
* "#! binary-path -i\n" (e.g., "#! /usr/local/bin/gforth-0.3.0 -i\n") |
* "#! binary-path -i\n" (e.g., "#! /usr/local/bin/gforth-0.4.0 -i\n") |
* padding to a multiple of 8 |
* padding to a multiple of 8 |
* magic: "Gforth1x" means format 0.2, |
* magic: "Gforth2x" means format 0.4, |
* where x is even for big endian and odd for little endian |
* where x is a byte with |
* and x & ~1 is the size of the cell in bytes. |
* bit 7: reserved = 0 |
|
* bit 6:5: address unit size 2^n octets |
|
* bit 4:3: character size 2^n octets |
|
* bit 2:1: cell size 2^n octets |
|
* bit 0: endian, big=0, little=1. |
|
* The magic are always 8 octets, no matter what the native AU/character size is |
* padding to max alignment (no padding necessary on current machines) |
* padding to max alignment (no padding necessary on current machines) |
* ImageHeader structure (see below) |
* ImageHeader structure (see below) |
* data (size in ImageHeader.image_size) |
* data (size in ImageHeader.image_size) |
Line 343 Address loader(FILE *imagefile, char* fi
|
Line 348 Address loader(FILE *imagefile, char* fi
|
Cell data_offset = offset_image ? 56*sizeof(Cell) : 0; |
Cell data_offset = offset_image ? 56*sizeof(Cell) : 0; |
UCell check_sum; |
UCell check_sum; |
static char* endianstring[]= { "big","little" }; |
static char* endianstring[]= { "big","little" }; |
|
Cell ausize = ((RELINFOBITS == 8) ? 0 : |
|
(RELINFOBITS == 16) ? 1 : |
|
(RELINFOBITS == 32) ? 2 : 3); |
|
Cell charsize = ((sizeof(Char) == 1) ? 0 : |
|
(sizeof(Char) == 2) ? 1 : |
|
(sizeof(Char) == 4) ? 2 : 3) + ausize; |
|
Cell cellsize = ((sizeof(Cell) == 1) ? 0 : |
|
(sizeof(Cell) == 2) ? 1 : |
|
(sizeof(Cell) == 4) ? 2 : 3) + ausize; |
|
|
#ifndef DOUBLY_INDIRECT |
#ifndef DOUBLY_INDIRECT |
check_sum = checksum(symbols); |
check_sum = checksum(symbols); |
Line 352 Address loader(FILE *imagefile, char* fi
|
Line 366 Address loader(FILE *imagefile, char* fi
|
|
|
do { |
do { |
if(fread(magic,sizeof(Char),8,imagefile) < 8) { |
if(fread(magic,sizeof(Char),8,imagefile) < 8) { |
fprintf(stderr,"%s: image %s doesn't seem to be a Gforth (>=0.2) image.\n", |
fprintf(stderr,"%s: image %s doesn't seem to be a Gforth (>=0.4) image.\n", |
progname, filename); |
progname, filename); |
exit(1); |
exit(1); |
} |
} |
preamblesize+=8; |
preamblesize+=8; |
} while(memcmp(magic,"Gforth1",7)); |
} while(memcmp(magic,"Gforth2",7)); |
if (debug) { |
if (debug) { |
magic[8]='\0'; |
magic[8]='\0'; |
fprintf(stderr,"Magic found: %s\n", magic); |
fprintf(stderr,"Magic found: %s\n", magic); |
} |
} |
|
|
if(magic[7] != sizeof(Cell) + |
if(magic[7] != (ausize << 5) + (charsize << 3) + (cellsize << 1) + |
#ifdef WORDS_BIGENDIAN |
#ifdef WORDS_BIGENDIAN |
'0' |
0 |
#else |
#else |
'1' |
1 |
#endif |
#endif |
) |
) |
{ fprintf(stderr,"This image is %d bit %s-endian, whereas the machine is %d bit %s-endian.\n", |
{ fprintf(stderr,"This image is %d bit cell, %d bit char, %d bit address unit %s-endian,\n" |
((magic[7]-'0')&~1)*8, endianstring[magic[7]&1], |
"whereas the machine is %d bit cell, %d bit char, %d bit address unit, %s-endian.\n", |
(int) sizeof(Cell)*8, endianstring[ |
(1<<((magic[7]>>1)&3))*8, |
|
(1<<((magic[7]>>3)&3))*8, |
|
(1<<((magic[7]>>5)&3))*8, |
|
endianstring[magic[7]&1], |
|
(1<<cellsize)*8, |
|
(1<<charsize)*8, |
|
(1<<ausize)*8, |
|
endianstring[ |
#ifdef WORDS_BIGENDIAN |
#ifdef WORDS_BIGENDIAN |
0 |
0 |
#else |
#else |