Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate a checksum for the system image #48869

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -3300,10 +3300,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 completeinfo)
Expand Down Expand Up @@ -3354,8 +3353,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 @@ -3366,7 +3366,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