Skip to content

Commit 3f040ca

Browse files
timholyKristofferC
authored andcommitted
Calculate a checksum for the system image (#48869)
(cherry picked from commit 48b4caa)
1 parent b710bd2 commit 3f040ca

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/staticdata.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3367,10 +3367,9 @@ static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *im
33673367
return restored;
33683368
}
33693369

3370-
static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image)
3370+
static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image, uint32_t checksum)
33713371
{
3372-
uint64_t checksum = 0; // TODO: make this real
3373-
jl_restore_system_image_from_stream_(f, image, NULL, checksum, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3372+
jl_restore_system_image_from_stream_(f, image, NULL, checksum | ((uint64_t)0xfdfcfbfa << 32), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
33743373
}
33753374

33763375
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)
@@ -3421,8 +3420,9 @@ JL_DLLEXPORT void jl_restore_system_image(const char *fname)
34213420
if (ios_readall(&f, sysimg, len) != len)
34223421
jl_errorf("Error reading system image file.");
34233422
ios_close(&f);
3423+
uint32_t checksum = jl_crc32c(0, sysimg, len);
34243424
ios_static_buffer(&f, sysimg, len);
3425-
jl_restore_system_image_from_stream(&f, &sysimage);
3425+
jl_restore_system_image_from_stream(&f, &sysimage, checksum);
34263426
ios_close(&f);
34273427
JL_SIGATOMIC_END();
34283428
}
@@ -3433,7 +3433,8 @@ JL_DLLEXPORT void jl_restore_system_image_data(const char *buf, size_t len)
34333433
ios_t f;
34343434
JL_SIGATOMIC_BEGIN();
34353435
ios_static_buffer(&f, (char*)buf, len);
3436-
jl_restore_system_image_from_stream(&f, &sysimage);
3436+
uint32_t checksum = jl_crc32c(0, buf, len);
3437+
jl_restore_system_image_from_stream(&f, &sysimage, checksum);
34373438
ios_close(&f);
34383439
JL_SIGATOMIC_END();
34393440
}

0 commit comments

Comments
 (0)