Skip to content

Commit 5f55b97

Browse files
authored
increase RELOC_TAG_OFFSET to handle larger system images (#37613)
add an error check that the max size is not exceeded
1 parent 5a86131 commit 5f55b97

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/staticdata.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ typedef enum {
168168
} jl_callingconv_t;
169169

170170

171-
// this supports up to 1 GB images and 16 RefTags
171+
// this supports up to 8 RefTags, 512MB of pointer data, and 4/2 (64/32-bit) GB of constant data.
172172
// if a larger size is required, will need to add support for writing larger relocations in many cases below
173-
#define RELOC_TAG_OFFSET 28
173+
#define RELOC_TAG_OFFSET 29
174174

175175

176176
/* read and write in host byte order */
@@ -1396,6 +1396,12 @@ static void jl_save_system_image_to_stream(ios_t *f)
13961396
jl_write_gv_ints(&s);
13971397
}
13981398

1399+
if (sysimg.size > ((uintptr_t)1 << RELOC_TAG_OFFSET) ||
1400+
const_data.size > ((uintptr_t)1 << RELOC_TAG_OFFSET)*sizeof(void*)) {
1401+
jl_printf(JL_STDERR, "ERROR: system image too large\n");
1402+
jl_exit(1);
1403+
}
1404+
13991405
// step 3: combine all of the sections into one file
14001406
write_uint32(f, sysimg.size - sizeof(uint32_t));
14011407
ios_seek(&sysimg, sizeof(uint32_t));

0 commit comments

Comments
 (0)