|
@@ -426,6 +426,7 @@ hl_code *hl_code_read( const unsigned char *data, int size ) {
|
|
hl_alloc alloc;
|
|
hl_alloc alloc;
|
|
int i;
|
|
int i;
|
|
int flags;
|
|
int flags;
|
|
|
|
+ int max_version = 5;
|
|
hl_alloc_init(&alloc);
|
|
hl_alloc_init(&alloc);
|
|
c = hl_zalloc(&alloc,sizeof(hl_code));
|
|
c = hl_zalloc(&alloc,sizeof(hl_code));
|
|
c->alloc = alloc;
|
|
c->alloc = alloc;
|
|
@@ -434,14 +435,16 @@ hl_code *hl_code_read( const unsigned char *data, int size ) {
|
|
EXIT("Invalid header");
|
|
EXIT("Invalid header");
|
|
r->code = c;
|
|
r->code = c;
|
|
c->version = READ();
|
|
c->version = READ();
|
|
- if( c->version <= 1 || c->version > 4 ) {
|
|
|
|
- printf("VER=%d\n",c->version);
|
|
|
|
|
|
+ if( c->version <= 1 || c->version > max_version ) {
|
|
|
|
+ printf("Found version %d while HL %d.%d supports up to %d\n",c->version,HL_VERSION>>8,(HL_VERSION>>4)&15,max_version);
|
|
EXIT("Unsupported bytecode version");
|
|
EXIT("Unsupported bytecode version");
|
|
}
|
|
}
|
|
flags = UINDEX();
|
|
flags = UINDEX();
|
|
c->nints = UINDEX();
|
|
c->nints = UINDEX();
|
|
c->nfloats = UINDEX();
|
|
c->nfloats = UINDEX();
|
|
c->nstrings = UINDEX();
|
|
c->nstrings = UINDEX();
|
|
|
|
+ if( c->version >= 5 )
|
|
|
|
+ c->nbytes = UINDEX();
|
|
c->ntypes = UINDEX();
|
|
c->ntypes = UINDEX();
|
|
c->nglobals = UINDEX();
|
|
c->nglobals = UINDEX();
|
|
c->nnatives = UINDEX();
|
|
c->nnatives = UINDEX();
|
|
@@ -461,6 +464,16 @@ hl_code *hl_code_read( const unsigned char *data, int size ) {
|
|
c->strings = hl_read_strings(r, c->nstrings, &c->strings_lens);
|
|
c->strings = hl_read_strings(r, c->nstrings, &c->strings_lens);
|
|
ALLOC(c->ustrings,uchar*,c->nstrings);
|
|
ALLOC(c->ustrings,uchar*,c->nstrings);
|
|
CHK_ERROR();
|
|
CHK_ERROR();
|
|
|
|
+ if( c->version >= 5 ) {
|
|
|
|
+ int size = hl_read_i32(r);
|
|
|
|
+ c->bytes = hl_malloc(&c->alloc,size);
|
|
|
|
+ hl_read_bytes(r,c->bytes,size);
|
|
|
|
+ ALLOC(c->bytes_pos,int,c->nbytes);
|
|
|
|
+ CHK_ERROR();
|
|
|
|
+ for(i=0;i<c->nbytes;i++)
|
|
|
|
+ c->bytes_pos[i] = UINDEX();
|
|
|
|
+ CHK_ERROR();
|
|
|
|
+ }
|
|
if( c->hasdebug ) {
|
|
if( c->hasdebug ) {
|
|
c->ndebugfiles = UINDEX();
|
|
c->ndebugfiles = UINDEX();
|
|
c->debugfiles = hl_read_strings(r, c->ndebugfiles, &c->debugfiles_lens);
|
|
c->debugfiles = hl_read_strings(r, c->ndebugfiles, &c->debugfiles_lens);
|