Bug 461675 - Partial linking results in corrupt .eh_frame_hdr
Summary: Partial linking results in corrupt .eh_frame_hdr
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: 9
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
Depends On: 458950
TreeView+ depends on / blocked
Reported: 2008-09-09 19:56 UTC by Brad Settlemyer
Modified: 2009-02-05 02:16 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2009-02-05 02:11:12 UTC
Type: ---

Attachments (Terms of Use)
Fix + testcase. (2.36 KB, patch)
2009-01-28 21:26 UTC, Jan Kratochvil
no flags Details | Diff

System ID Priority Status Summary Last Updated
Sourceware 6893 None None None Never

Description Brad Settlemyer 2008-09-09 19:56:08 UTC
Description of problem:
I use partial linking in my project.  No matter how I try to configure it, I seem to get a corrupt .eh_frame_hdr in the final (fully linked) executable.

Version-Release number of selected component (if applicable):

How reproducible:
Every Time.

Steps to Reproduce:
1.  ld -Ur --eh-frame-hdr $(RANDOM_CPP_OBJS) -o partial_obj.o 
2.  g++ -Wl,--export-dynamic $(MORE_OBJS) partial_obj.o -o final.exe
Actual results:
/usr/bin/ld: error in lib/partial_obj.o(.eh_frame); no .eh_frame_hdr table will be created.

Expected results:

Additional info:
The executable generated seems to work okay, though what happens on an actual excpetion is in doubt for me.

Comment 1 Jan Kratochvil 2008-09-16 14:11:40 UTC
Upstream post:

Comment 2 Jan Kratochvil 2008-09-16 14:12:38 UTC

*** This bug has been marked as a duplicate of bug 458950 ***

Comment 3 Brad Settlemyer 2009-01-27 15:28:06 UTC
Please reopen this bug, it is not a duplicate of 458950 because that bug is fixed, and my problem still persists.  I will add a test case for reproducing the bug later.  That will take some time because the only system I've got that produces the bug is complicated, and I don't have an easy way to pare it down.

Comment 4 Jan Kratochvil 2009-01-27 15:44:55 UTC
In fact some binary ball would be also useful as you write in your comment in Bug 458950 Comment 10.

Comment 5 Brad Settlemyer 2009-01-27 17:46:10 UTC
Okay, here are the binaries in question, and a script that links the partial object, and then the final executable.  I realize we are well off into the woods on the linker features in use here.  I've never even seen .a's linked by anyone like that, but that is what the packagers of the libs I use did to me.

Here is a link:


The download is 13MB, and it creates a single dedicated directory.  Nothing malicious in there, just a call to ld, followed by a call to g++.

Comment 6 Jan Kratochvil 2009-01-28 21:26:03 UTC
Created attachment 330285 [details]
Fix + testcase.

My former patch was: http://sourceware.org/ml/binutils/2008-09/msg00124.html
Relaxed the check there with a comment:
+         /* For NULL RSEC (cleared FDE belonging to a discarded section)
+            the relocations are commonly cleared.  We do not sanity check if
+            all these relocations are cleared as (1) relocations to
+            .gcc_except_table will remain uncleared (they will get dropped
+            with the drop of this unused FDE) and (2) BFD already safely drops
+            relocations of any type to .eh_frame by
+            elf_section_ignore_discarded_relocs.
+            FIXME: The .gcc_except_table entries should be also filtered as
+            .eh_frame entries; moreover both could rather use COMDAT.  */

Fortunately the former patch had no regressions just its effect was incomplete.

Thanks for the bugreport, scratch build (-U --oldpackage, please) is at:

After the multiarch regression tests going to post it upstream.

Comment 7 Jan Kratochvil 2009-01-31 11:04:25 UTC
Post upstream with an updated testcase:

Comment 8 Fedora Update System 2009-02-05 02:11:09 UTC
binutils- has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2009-02-05 02:16:12 UTC
binutils- has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.