Skip to content

Commit

Permalink
Calculate a checksum for the system image (#48869)
Browse files Browse the repository at this point in the history
(cherry picked from commit 48b4caa)
  • Loading branch information
timholy authored and KristofferC committed Mar 3, 2023
1 parent 0c8d625 commit 870c223
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -3367,10 +3367,9 @@ static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *im
return restored;
}

static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image)
static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image, uint32_t checksum)
{
uint64_t checksum = 0; // TODO: make this real
jl_restore_system_image_from_stream_(f, image, NULL, checksum, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
jl_restore_system_image_from_stream_(f, image, NULL, checksum | ((uint64_t)0xfdfcfbfa << 32), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}

JL_DLLEXPORT jl_value_t *jl_restore_incremental_from_buf(const char *buf, jl_image_t *image, size_t sz, jl_array_t *depmods, int complete)
Expand Down Expand Up @@ -3421,8 +3420,9 @@ JL_DLLEXPORT void jl_restore_system_image(const char *fname)
if (ios_readall(&f, sysimg, len) != len)
jl_errorf("Error reading system image file.");
ios_close(&f);
uint32_t checksum = jl_crc32c(0, sysimg, len);
ios_static_buffer(&f, sysimg, len);
jl_restore_system_image_from_stream(&f, &sysimage);
jl_restore_system_image_from_stream(&f, &sysimage, checksum);
ios_close(&f);
JL_SIGATOMIC_END();
}
Expand All @@ -3433,7 +3433,8 @@ JL_DLLEXPORT void jl_restore_system_image_data(const char *buf, size_t len)
ios_t f;
JL_SIGATOMIC_BEGIN();
ios_static_buffer(&f, (char*)buf, len);
jl_restore_system_image_from_stream(&f, &sysimage);
uint32_t checksum = jl_crc32c(0, buf, len);
jl_restore_system_image_from_stream(&f, &sysimage, checksum);
ios_close(&f);
JL_SIGATOMIC_END();
}
Expand Down

0 comments on commit 870c223

Please sign in to comment.