Skip to content

Commit 7c7e8b6

Browse files
JeffBezansonKristofferC
authored andcommitted
increase RELOC_TAG_OFFSET to handle larger system images (#37613)
add an error check that the max size is not exceeded (cherry picked from commit 5f55b97)
1 parent b32702d commit 7c7e8b6

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
@@ -166,9 +166,9 @@ typedef enum {
166166
} jl_callingconv_t;
167167

168168

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

173173

174174
/* read and write in host byte order */
@@ -1394,6 +1394,12 @@ static void jl_save_system_image_to_stream(ios_t *f)
13941394
jl_write_gv_ints(&s);
13951395
}
13961396

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

0 commit comments

Comments
 (0)