Skip to content

Commit

Permalink
increase RELOC_TAG_OFFSET to handle larger system images (#37613)
Browse files Browse the repository at this point in the history
add an error check that the max size is not exceeded

(cherry picked from commit 5f55b97)
  • Loading branch information
JeffBezanson authored and KristofferC committed Oct 21, 2020
1 parent b32702d commit 7c7e8b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ typedef enum {
} jl_callingconv_t;


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


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

if (sysimg.size > ((uintptr_t)1 << RELOC_TAG_OFFSET) ||
const_data.size > ((uintptr_t)1 << RELOC_TAG_OFFSET)*sizeof(void*)) {
jl_printf(JL_STDERR, "ERROR: system image too large\n");
jl_exit(1);
}

// step 3: combine all of the sections into one file
write_uint32(f, sysimg.size - sizeof(uint32_t));
ios_seek(&sysimg, sizeof(uint32_t));
Expand Down

0 comments on commit 7c7e8b6

Please sign in to comment.