This is the mail archive of the binutils@sourceware.org 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: [patch,PE-COFF,head+2.22] Don't generate bogus base relocs in .eh_frame of DLLs.


On 05/10/2011 07:16, Ozkan Sezer wrote:
>>  The latest release of the libstdc++ DLL for Cygwin breaks exception handling
>> if it is rebased away from its default address.  Debugging this shows that one
>> of the Dwarf-2 FDEs in the .eh_frame section gets mangled, which causes the
>> libgcc unwind code to get confused and fail to find the FDE for a given return
>> address from the stack frame, resulting in an early exit through terminate().

>>  The attached patch is conservative; it checks just for BFD against symbols
>>from discarded input sections, and if the reloc itself is in an EH section it
>> doesn't generate a corresponding base reloc.  It doesn't cause any failures in
>> the ld testsuite, but then I don't think we have anything to verify base reloc
>> generation in there anyway, so I'm also running a GCC bootstrap and test cycle
>> using the patched binutils.

> This patch still isn't in. Is it not needed any more?

  The testing revealed that the patch was not conservative enough; there were
still failures caused in the libstdc++ testsuite when the libstdc++ DLL got
rebased.  So I had to reanalyze the new failures, respin the patch, rebuild
and test GCC... it took a little while!  The problem turned out to be that it
was wrong to not generate base relocs from .gcc_except_table sections against
symbols in discarded input sections, as the underlying BFD relocs do in fact
get resolved against the equivalent kept section.  It is only in the .eh_frame
sections that the underlying BFD reloc gets discarded, and hence only those
base relocs that should not be emitted.

  Attached is the fixed version of the patch, which passed the GCC C++
testsuites without any change in the results upon rebasing the libstdc++ DLL.

2011-10-13  Dave Korn  <dave.korn.cygwin@...

	* pe-dll.c (generate_reloc): Don't emit a base reloc for an
	underlying BFD reloc that will be discarded in eh_frame data.

  Committed to trunk and 2_22 branch.

    cheers,
      DaveK


Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.138
diff -p -u -r1.138 pe-dll.c
--- ld/pe-dll.c	16 Sep 2011 01:15:19 -0000	1.138
+++ ld/pe-dll.c	13 Oct 2011 02:31:34 -0000
@@ -1395,6 +1395,15 @@ generate_reloc (bfd *abfd, struct bfd_li
 		      else if (!blhe || blhe->type != bfd_link_hash_defined)
 			continue;
 		    }
+		  /* Nor for Dwarf FDE references to discarded sections.  */
+		  else if (bfd_is_abs_section (sym->section->output_section))
+		    {
+		      /* We only ignore relocs from .eh_frame sections, as
+			 they are discarded by the final link rather than
+			 resolved against the kept section.  */
+		      if (!strcmp (s->name, ".eh_frame"))
+			continue;
+		    }
 
 		  reloc_data[total_relocs].vma = sec_vma + relocs[i]->address;
 

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