This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: [BUG] Regression in 2.14.90 (relative to 2.13.90)


Hi Carlo, Hi HJ,

> I am convinced the bug is still there.  When I *only* replace
> 'ld', then I can flip the existence of the bug on or off.

> As you see, the bug appears by JUST and ONLY using the 'ld' from
> todays CVS. 

Yup - and I believe that I have now found it.  It appears to be a
result of this patch from HJ:

  http://sources.redhat.com/ml/binutils/2003-06/msg00550.html
  
I am attaching a patch below which appears to fix the problem.

HJ - do you think that my patch is correct ?  I could not tell from
the email dialogue the derivation of the heuristic to determine if a
debug section should be kept, but I think that my addition to it is
reasonable.

Cheers
        Nick

2003-11-25  Nick Clifton  <nickc@redhat.com>

	* elflink.h (GNU_LINKONCE): New macro: The prefix of .gnu.linkonce sections.
	(PRESERVABLE_DEBUG_SECTION): New macro.  Determine if a
	unreferenced section containing debug info should be kept.  Make
	sure that .gnu.linkonce sections are not kept.
	(elf_link_input_bfd): Use PRESERVABLE_DEBUG_SECTION

Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.247
diff -c -3 -p -r1.247 elflink.h
*** bfd/elflink.h	11 Nov 2003 13:32:38 -0000	1.247
--- bfd/elflink.h	25 Nov 2003 15:12:29 -0000
*************** elf_link_output_extsym (struct elf_link_
*** 4653,4658 ****
--- 4653,4669 ----
    return TRUE;
  }
  
+ /* Macro to decide if a section containing debug info should be preserved
+    despite the fact that it is not referenced by any other section.  The
+    heuristic is: keep sections which have a kept equivalent of the same
+    size unless they are special g++ created sections which should only ever
+    exist in one place.  */
+ #define GNU_LINKONCE ".gnu.linkonce"
+ #define PRESERVABLE_DEBUG_SECTION(sec)					\
+   ((sec)->kept_section != NULL						\
+    && (sec)->_raw_size == sec->kept_section->_raw_size			\
+    && strncmp ((sec)->name, GNU_LINKONCE, sizeof GNU_LINKONCE - 1) != 0)
+ 			   
  /* Link an input file into the linker output file.  This function
     handles all the sections and relocations of the input file at once.
     This is so that we only have to read the local symbols once, and
*************** elf_link_input_bfd (struct elf_final_lin
*** 4941,4951 ****
  			    {
  			      BFD_ASSERT (r_symndx != 0);
  			      /* Try to preserve debug information.  */
  			      if ((o->flags & SEC_DEBUGGING) != 0
! 				  && sec->kept_section != NULL
! 				  && sec->_raw_size == sec->kept_section->_raw_size)
! 				h->root.u.def.section
! 				  = sec->kept_section;
  			      else
  				memset (rel, 0, sizeof (*rel));
  			    }
--- 4952,4961 ----
  			    {
  			      BFD_ASSERT (r_symndx != 0);
  			      /* Try to preserve debug information.  */
+ 			      
  			      if ((o->flags & SEC_DEBUGGING) != 0
! 				  && PRESERVABLE_DEBUG_SECTION (sec))
! 				h->root.u.def.section = sec->kept_section;
  			      else
  				memset (rel, 0, sizeof (*rel));
  			    }
*************** elf_link_input_bfd (struct elf_final_lin
*** 4971,4978 ****
  			      BFD_ASSERT (r_symndx != 0);
  			      /* Try to preserve debug information.  */
  			      if ((o->flags & SEC_DEBUGGING) != 0
! 				  && sec->kept_section != NULL
! 				  && sec->_raw_size == sec->kept_section->_raw_size)
  				finfo->sections[r_symndx]
  				  = sec->kept_section;
  			      else
--- 4981,4987 ----
  			      BFD_ASSERT (r_symndx != 0);
  			      /* Try to preserve debug information.  */
  			      if ((o->flags & SEC_DEBUGGING) != 0
! 				  && PRESERVABLE_DEBUG_SECTION (sec))
  				finfo->sections[r_symndx]
  				  = sec->kept_section;
  			      else
        


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