Skip to content

Commit 48b4caa

Browse files
authored
Calculate a checksum for the system image (#48869)
1 parent 3c7ca40 commit 48b4caa

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
@@ -3300,10 +3300,9 @@ static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *im
33003300
return restored;
33013301
}
33023302

3303-
static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image)
3303+
static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image, uint32_t checksum)
33043304
{
3305-
uint64_t checksum = 0; // TODO: make this real
3306-
jl_restore_system_image_from_stream_(f, image, NULL, checksum, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
3305+
jl_restore_system_image_from_stream_(f, image, NULL, checksum | ((uint64_t)0xfdfcfbfa << 32), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
33073306
}
33083307

33093308
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)
@@ -3354,8 +3353,9 @@ JL_DLLEXPORT void jl_restore_system_image(const char *fname)
33543353
if (ios_readall(&f, sysimg, len) != len)
33553354
jl_errorf("Error reading system image file.");
33563355
ios_close(&f);
3356+
uint32_t checksum = jl_crc32c(0, sysimg, len);
33573357
ios_static_buffer(&f, sysimg, len);
3358-
jl_restore_system_image_from_stream(&f, &sysimage);
3358+
jl_restore_system_image_from_stream(&f, &sysimage, checksum);
33593359
ios_close(&f);
33603360
JL_SIGATOMIC_END();
33613361
}
@@ -3366,7 +3366,8 @@ JL_DLLEXPORT void jl_restore_system_image_data(const char *buf, size_t len)
33663366
ios_t f;
33673367
JL_SIGATOMIC_BEGIN();
33683368
ios_static_buffer(&f, (char*)buf, len);
3369-
jl_restore_system_image_from_stream(&f, &sysimage);
3369+
uint32_t checksum = jl_crc32c(0, buf, len);
3370+
jl_restore_system_image_from_stream(&f, &sysimage, checksum);
33703371
ios_close(&f);
33713372
JL_SIGATOMIC_END();
33723373
}

0 commit comments

Comments
 (0)