Bug 676194 - ld segfaults on arch mismatch of objects when linking
Summary: ld segfaults on arch mismatch of objects when linking
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: binutils
Version: 6.0
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Nick Clifton
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-09 02:42 UTC by Anthony Symons
Modified: 2012-06-20 14:03 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-20 14:03:35 UTC
Target Upstream Version:


Attachments (Terms of Use)
objects and script to reproduce the crash on rhel6.0 x86_64 (335.57 KB, application/x-gzip)
2011-02-09 02:42 UTC, Anthony Symons
no flags Details
Detect attempts to link mixed binaries and prevent the linker from seg-faulting (28.96 KB, application/bzip2)
2012-01-05 16:43 UTC, Nick Clifton
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0872 0 normal SHIPPED_LIVE binutils bug fix and enhancement update 2012-06-19 20:47:50 UTC

Description Anthony Symons 2011-02-09 02:42:59 UTC
Created attachment 477723 [details]
objects and script to reproduce the crash on rhel6.0 x86_64

Description of problem:

Testing a build on rhel6, I noticed the following:

gcc -o gen-LINUX_V6/prosody_thread ../libutil/gen-LINUX_V6/generic_io.o gen-LINUX_V6/prosody_thread.o -lpthread 2>&1 | t0 errs/gen-LINUX_V6/prosody_thread
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
/usr/bin/ld: i386 architecture of input file `../libutil/gen-LINUX_V6/generic_io.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `gen-LINUX_V6/prosody_thread.o' is incompatible with i386:x86-64 output


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

binutils-2.20.51.0.2-5.11.el6.x86_64

How reproducible:

everytime, with attached test case

Steps to Reproduce:
1. untar attached source, run crash.sh on x86_64 arch
2.
3.
  
Actual results:

[root@localhost ld_crash]# ./crash.sh 
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
/usr/bin/ld: i386 architecture of input file `generic_io.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `prosody_thread.o' is incompatible with i386:x86-64 output


Expected results:

Not sure, probably a successful link :) or another error but no crash.

Additional info:

Comment 2 Andreas Schwab 2011-02-10 10:59:37 UTC
Just use -m32.

Comment 3 Eric Bachalo 2011-03-03 14:47:53 UTC
Anthony Symons,

Does using the gcc command line option -m32, fix your problem?

Comment 7 RHEL Program Management 2011-04-04 01:50:01 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 8 Jeff Law 2011-06-15 19:44:33 UTC
Even though this is a user-error mixing objects of different types, the linker still shouldn't segfault.  Instead it should gracefully exit after issuing the error.

Comment 9 Jeff Law 2011-09-28 15:53:29 UTC
Moving to 6.3

Comment 12 Nick Clifton 2012-01-05 16:43:41 UTC
Created attachment 550962 [details]
Detect attempts to link mixed binaries and prevent the linker from seg-faulting

Comment 13 Nick Clifton 2012-01-05 16:53:56 UTC
I have uploaded a proposed patch to fix this bug.  It is based on a patch applied to the mainline FSF binutils sources.  (Thanks to Jeff Law for extracting this part of the patch for me).

The patch also includes a new linker testcase that reproduces the bug without requiring pre-built binaries.  With the full patch applied and the linker testsuite run for an x86_64-* targeted set of the binutils the following new entries will appear in the ld.sum file:

  PASS: build 32-bit object
  PASS: build 64-bit object
  PASS: link mixed objects

Without the bugfix part of the patch applied (binutils-rh676194.patch) but with the new testcase applied, the following new entries should appear in the ld.sum file:

  PASS: build 32-bit object
  PASS: build 64-bit object
  FAIL: link mixed objects

Comment 20 errata-xmlrpc 2012-06-20 14:03:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0872.html


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