]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto/122515: Avoid using SSIZE_MAX
authorSiddhesh Poyarekar <siddhesh@gotplt.org>
Tue, 25 Nov 2025 01:32:08 +0000 (20:32 -0500)
committerSiddhesh Poyarekar <siddhesh@gotplt.org>
Tue, 25 Nov 2025 16:30:33 +0000 (11:30 -0500)
SSIZE_MAX may not always be available, so build it using (size_t) -1
instead.

gcc/lto/ChangeLog:

PR lto/122515
* lto-common.cc (lto_read_section_data): Avoid using SSIZE_MAX.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
gcc/lto/lto-common.cc

index 3d35c0389161069747d005e7ca881f3438cca3b8..13aca2c9d2afbdd8d3a6a0b4fc94498da6087f8d 100644 (file)
@@ -2438,7 +2438,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
 
   computed_offset = offset & ((off_t) page_mask);
   diff = offset - computed_offset;
-  if (len > (size_t) (SSIZE_MAX - diff))
+  if (len > (((size_t) -1) >> 1) - diff)
     {
       fatal_error (input_location, "Cannot map %s: section is too long",
                   file_data->file_name);