Bug 338221 - ld --build-id crashes when linker script discards .note.gnu.build-id section
Summary: ld --build-id crashes when linker script discards .note.gnu.build-id section
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: rawhide
Hardware: All
OS: Linux
medium
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: fedora-ia64
TreeView+ depends on / blocked
 
Reported: 2007-10-18 16:06 UTC by Doug Chapman
Modified: 2008-03-05 21:17 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2008-03-05 21:17:43 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
file to be used in reproducer as described in original report (45 bytes, text/plain)
2007-10-18 16:06 UTC, Doug Chapman
no flags Details
linker script (180 bytes, application/octet-stream)
2007-10-18 19:39 UTC, Roland McGrath
no flags Details
linker script for test case (242 bytes, text/plain)
2007-10-18 19:58 UTC, Roland McGrath
no flags Details
machine-neutral assembly source test case (45 bytes, text/plain)
2007-10-18 19:59 UTC, Roland McGrath
no flags Details

Description Doug Chapman 2007-10-18 16:06:06 UTC
Description of problem:
This was found while attempting to bring up Fedora on ia64.  To make things
easier I have a reproducer method that can be done under RHEL5.1 since we don't
have complete Fedora bits for ia64 yet.

The gcc patch: gcc41-build-id.patch creates a regression on ia64 that causes a
segv when compiling the kernel.  It is a very simple .S file it is compiling as
a check.  I will attach the .S file here.


# gcc -nostdlib -static -Wl,-T./check-segrel.lds ./check-segrel.S

collect2: ld terminated with signal 11 [Segmentation fault]



It appears that something doesn't like having the --build-id argument passed in
as this bit of patch is what introduced the problem:

--- gcc/config/ia64/linux.h.~1~

+++ gcc/config/ia64/linux.h

@@ -56,7 +56,7 @@ do {                                          \

    Signalize that because we have fde-glibc, we don't need all C shared libs

    linked against -lgcc_s.  */

 #undef LINK_EH_SPEC

-#define LINK_EH_SPEC ""

+#define LINK_EH_SPEC "%{!r:--build-id} "

 

 #define MD_UNWIND_SUPPORT "config/ia64/linux-unwind.h"


when I back this bit out the segv no longer happens

Version-Release number of selected component (if applicable):
gcc-4.1.2-31.src.rpm

How reproducible:
100%

Steps to Reproduce:
Easiest to reproduce is to install RHEL5.1 and do the following:
1. install gcc-4.1.2-31.src.rpm
2. rpmbuild -bp --nodeps gcc41.spec
3. cd ../BUILD/gcc-4.1.2-20070925
4. mkdir build
5. cd build
6. ../configure --prefix=/usr/local --enable-languages=c
7. make -j4
8. make install
9. /usr/local/bin/gcc -nostdlib -static \
-Wl,-T./check-segrel.lds ./check-segrel.S

  
Actual results:
SEGV

Expected results:
should compile quietly


Additional info:

Comment 1 Doug Chapman 2007-10-18 16:06:06 UTC
Created attachment 231161 [details]
file to be used in reproducer as described in original report

Comment 2 Doug Chapman 2007-10-18 16:07:42 UTC
Adding Roland to the CC since it appears this was his patch.

Roland, any idea why this causes a problem?  Would there be any problems with
pulling this out at least for ia64?


Comment 3 Jakub Jelinek 2007-10-18 19:13:28 UTC
This doesn't have much to do with gcc, it is ld that segfaulted.  What version
of ld (nvr of binutils) are you using?

Comment 4 Roland McGrath 2007-10-18 19:39:29 UTC
Created attachment 231431 [details]
linker script

The important thing to the bug is probably the linker script, not the assembly
source.

Comment 5 Roland McGrath 2007-10-18 19:41:49 UTC
Probably a sufficient workaround for the ld problem is to change:

	.rodata : { *(.rodata) } :ro

to:

	.rodata : { *(.rodata) *(.note*) } :ro

in check-segrel.lds.  

Comment 6 Doug Chapman 2007-10-18 19:48:41 UTC
(In reply to comment #3)
> This doesn't have much to do with gcc, it is ld that segfaulted.  What version
> of ld (nvr of binutils) are you using?

I saw this with binutils-2.17.50.0.18-1, I should note that when I reproduced
this on RHEL5.1 I had to update to that version of binutils or I would get
errors such as "unrecognized option '--build-id'" since the ld on RHEL5.1
doesn't recognize that option.

The specific version of ld I am using is:

# ld --version

GNU ld version 2.17.50.0.6-5.el5 20061020



Comment 7 Roland McGrath 2007-10-18 19:57:45 UTC
binutils-2.17.50.0.18-1 on x86_64 reproduces a crash

Comment 8 Roland McGrath 2007-10-18 19:58:44 UTC
Created attachment 231471 [details]
linker script for test case

Comment 9 Roland McGrath 2007-10-18 19:59:48 UTC
Created attachment 231481 [details]
machine-neutral assembly source test case

as -o s.o s.s; ld --build-id -T s.lds s.o

Comment 10 Doug Chapman 2008-03-05 21:17:43 UTC
no longer seeing a segfault here, calling it closed.



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