The version 4 image format did not write 0 into reserved_* fields (#2580).
Therefore current version 4 images are not forward compatible with image versions that use these fields.
By introducing an escape code 0 into the data_size field,
three reserved_* fields now become available for redefinition, while keeping image version at 4.
This version can transparently read regular v4 image files, as well as ones with h.data_size=0 and h.escaped_data_size=data_size
if (h.version != image_version)
fatal_error("Bad image: version number check failed", h.version);
+ if (!h.version4_escape) h.data_size=h.escaped_data_size, h.escaped_data_size=0;
+
load_data_heap(file, &h, p);
load_code_heap(file, &h, p);
cell version;
// base address of data heap when image was saved
cell data_relocation_base;
- // size of heap
- cell data_size;
+ // size of data heap
+ union { cell data_size; cell version4_escape; };
// base address of code heap when image was saved
cell code_relocation_base;
// size of code heap
cell code_size;
- cell reserved_1;
+ union { cell reserved_1; cell escaped_data_size; };
cell reserved_2;
cell reserved_3;
cell reserved_4;