This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto] PATCH: read correct number of bytes for DW_FORM_addr


Here's a fix for a nasty little bug -- we were reading the wrong number of bytes for attributes using DW_FORM_addr, so that the reader was losing track of where it was in the file and failing to associate child DIEs with their parents.

OK to commit?

-Sandra

2006-10-10  Sandra Loosemore  <sandra@codesourcery.com>

	* gcc/lto/lto.c (lto_read_comp_unit_header): Add sanity check
	on cu_pointer_size.
	(lto_read_form): DW_FORM_addr data size is controlled by the
	cu_pointer_size in the compilation unit header, not the dwarf64/32
	file attribute.
Index: gcc/lto/lto.c
===================================================================
*** gcc/lto/lto.c	(revision 117614)
--- gcc/lto/lto.c	(working copy)
*************** lto_read_comp_unit_header (lto_info_fd *
*** 603,608 ****
--- 603,610 ----
    cu->cu_version = lto_read_uhalf (basefd);
    cu->cu_abbrev_offset = lto_read_section_offset (basefd);
    cu->cu_pointer_size = lto_read_ubyte (basefd);
+   if (cu->cu_pointer_size * BITS_PER_UNIT != POINTER_SIZE)
+     lto_abi_mismatch_error ();
  }
  
  /* Find the compilation unit in FD that contains the DWARF2 DIE
*************** lto_read_form (lto_info_fd *info_fd, 
*** 818,825 ****
    switch (form)
      {
      case DW_FORM_addr:
        out->cl = DW_cl_address;
!       fd->dwarf64 ? lto_read_udword (fd) : lto_read_uword (fd);
        break;
  
      case DW_FORM_string:
--- 820,831 ----
    switch (form)
      {
      case DW_FORM_addr:
+       /* Addresses are not useful without relocation info, so just skip
+ 	 over the appropriate number of bytes.  */
        out->cl = DW_cl_address;
!       fd->cur += context->cu->cu_pointer_size;
!       if (fd->cur > context->cu_end)
! 	lto_file_corrupt_error (fd);
        break;
  
      case DW_FORM_string:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]