We're doing the LTO bytecode version check only for two section
types at the moment - specifically _not_ for the first section
we read.  Which causes us to crash instead of reporting a
version mismatch ...

Fixed by doing the version check in the most appropriate place.

LTO bootstrapped on x86_64-unknown-linux-gnu, applied.

Richard.

2014-03-04  Richard Biener  <rguent...@suse.de>

        PR lto/60405
        * lto-streamer-in.c (lto_read_body): Remove LTO bytecode version
        check.
        (lto_input_toplevel_asms): Likewise.
        * lto-section-in.c (lto_get_section_data): Instead do it here
        for every section.

Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c       (revision 208305)
--- gcc/lto-streamer-in.c       (working copy)
*************** lto_read_body (struct lto_file_decl_data
*** 1059,1068 ****
    data_in = lto_data_in_create (file_data, data + string_offset,
                              header->string_size, vNULL);
  
-   /* Make sure the file was generated by the exact same compiler.  */
-   lto_check_version (header->lto_header.major_version,
-                    header->lto_header.minor_version);
- 
    if (section_type == LTO_section_function_body)
      {
        struct lto_in_decl_state *decl_state;
--- 1059,1064 ----
*************** lto_input_toplevel_asms (struct lto_file
*** 1331,1340 ****
    data_in = lto_data_in_create (file_data, data + string_offset,
                              header->string_size, vNULL);
  
-   /* Make sure the file was generated by the exact same compiler.  */
-   lto_check_version (header->lto_header.major_version,
-                    header->lto_header.minor_version);
- 
    while ((str = streamer_read_string_cst (data_in, &ib)))
      {
        struct asm_node *node = add_asm_node (str);
--- 1327,1332 ----
Index: gcc/lto-section-in.c
===================================================================
*** gcc/lto-section-in.c        (revision 208305)
--- gcc/lto-section-in.c        (working copy)
*************** lto_get_section_data (struct lto_file_de
*** 153,178 ****
  
    /* FIXME lto: WPA mode does not write compressed sections, so for now
       suppress uncompression if flag_ltrans.  */
!   if (flag_ltrans)
!     return data;
! 
!   /* Create a mapping header containing the underlying data and length,
!      and prepend this to the uncompression buffer.  The uncompressed data
!      then follows, and a pointer to the start of the uncompressed data is
!      returned.  */
!   header = (struct lto_data_header *) xmalloc (header_length);
!   header->data = data;
!   header->len = *len;
! 
!   buffer.data = (char *) header;
!   buffer.length = header_length;
! 
!   stream = lto_start_uncompression (lto_append_data, &buffer);
!   lto_uncompress_block (stream, data, *len);
!   lto_end_uncompression (stream);
! 
!   *len = buffer.length - header_length;
!   return buffer.data + header_length;
  }
  
  
--- 153,182 ----
  
    /* FIXME lto: WPA mode does not write compressed sections, so for now
       suppress uncompression if flag_ltrans.  */
!   if (!flag_ltrans)
!     {
!       /* Create a mapping header containing the underlying data and length,
!        and prepend this to the uncompression buffer.  The uncompressed data
!        then follows, and a pointer to the start of the uncompressed data is
!        returned.  */
!       header = (struct lto_data_header *) xmalloc (header_length);
!       header->data = data;
!       header->len = *len;
! 
!       buffer.data = (char *) header;
!       buffer.length = header_length;
! 
!       stream = lto_start_uncompression (lto_append_data, &buffer);
!       lto_uncompress_block (stream, data, *len);
!       lto_end_uncompression (stream);
! 
!       *len = buffer.length - header_length;
!       data = buffer.data + header_length;
!     }
! 
!   lto_check_version (((lto_header *)data)->major_version,
!                    ((lto_header *)data)->minor_version);
!   return data;
  }
  
  

Reply via email to